
/*************************************************************************
 * ADOBE CONFIDENTIAL
 * ___________________
 *
 * Copyright 2021 Adobe. All Rights Reserved.
 *
 * NOTICE: All information contained herein is, and remains
 * the property of Adobe and its suppliers, if any. The intellectual
 * and technical concepts contained herein are proprietary to Adobe
 * and its suppliers and are protected by all applicable intellectual
 * property laws, including trade secret and copyright laws.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe.
 **************************************************************************/

(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{twrL:function(e,t,n){(function(t){
/************************************************************************!
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2015-2020 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
e.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){function n(e,t,i){if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,n);else{var o=new Error;o.name=this.name,this.stack=o.stack}this.code=e,this.message="["+e+"] "+t,this.underlyingError=i}n.prototype=Object.create(Error.prototype),n.prototype.name="AdobeDCXError",n.INVALID_JSON="INVALID_JSON",n.READ_ONLY="READ_ONLY",n.INVALID_PARAMS="",n.INVALID_DATA="INVALID_DATA",n.DUPLICATE_VALUE="DUPLICATE_VALUE",n.NO_LOCAL_STORAGE="NO_LOCAL_STORAGE",n.INVALID_STATE="INVALID_STATE",n.DELETED_COMPOSITE="DELETED_COMPOSITE",n.UNEXPECTED_RESPONSE="UNEXPECTED_RESPONSE",n.ACCESS_DENIED="ACCESS_DENIED",n.NETWORK_ERROR="NETWORK_ERROR",n.COMPONENT_DOWNLOAD_ERROR="COMPONENT_DOWNLOAD_ERROR",n.COMPONENT_UPLOAD_ERROR="COMPONENT_UPLOAD_ERROR",n.COMPONENT_MODIFIED_ERROR="COMPONENT_MODIFIED_ERROR",n.UPDATE_CONFLICT="UPDATE_CONFLICT",n.NO_COMPOSITE="NO_COMPOSITE",n.ALREADY_EXISTS="ALREADY_EXISTS",n.SERVICE_IS_INACTIVE="SERVICE_IS_INACTIVE",n.EXCEEDS_QUOTA="EXCEEDS_QUOTA",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",n.TIMED_OUT="TIMED_OUT",n.UNEXPECTED="UNEXPECTED",n.TERMINATED_INPUTSTREAM="TERMINATED_INPUTSTREAM",n.WRONG_ENDPOINT="WRONG_ENDPOINT",n.OUT_OF_SPACE="ENOSPC";var i={};i[n.SERVICE_IS_INACTIVE]=1,i[n.NOT_IMPLEMENTED]=1,i[n.EXCEEDS_QUOTA]=1,i[n.RETRYABLE_SERVER_ERROR]=1,i[n.TIMED_OUT]=1,i[n.TERMINATED_INPUTSTREAM]=1,i[n.WRONG_ENDPOINT]=1,i[n.OUT_OF_SPACE]=1,n.wrapError=function(e,t,o,r){if(!o||!i[o.code]){if(r){var a=r.statusCode;a>=500&&a<600?501===a?(e=n.NOT_IMPLEMENTED,t="Unimplemented request"):507===a?(e=n.EXCEEDS_QUOTA,t="Quota exceeded"):(e=n.RETRYABLE_SERVER_ERROR,t="Server error"):429===a&&(e=n.RETRYABLE_SERVER_ERROR,t="Too many requests")}o=new n(e,t,o)}return r&&(o.response=r),o},n.networkError=function(e,t,i){return n.wrapError(n.NETWORK_ERROR,e,t,i)},n.unexpectedResponse=function(e,t,i){return n.wrapError(n.UNEXPECTED_RESPONSE,e,t,i)},e.exports=n},function(e,t){var n=["INVALID_PARAMETER","READ_ONLY","NOT_IMPLEMENTED","NOT_SUPPORTED","REQUIRES_FILESYSTEM","DELETED_LOCALLY"];function i(e,t,o,r){if(-1!==n.indexOf(e))if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,i);else{var a=new Error;a.name=this.name,this.stack=a.stack}this.code=e,this._message=t,this.message="["+e+"] "+t,this.libraryId=o,this.underlyingError=r}i.prototype=Object.create(Error.prototype),i.prototype.name="AdobeLibraryError",i.INVALID_PARAMETER="INVALID_PARAMETER",i.READ_ONLY="READ_ONLY",i.NOT_IMPLEMENTED="NOT_IMPLEMENTED",i.NOT_SUPPORTED="NOT_SUPPORTED",i.REQUIRES_FILESYSTEM="REQUIRES_FILESYSTEM",i.DELETED_LOCALLY="DELETED_LOCALLY",i.NOT_ALLOWED="NOT_ALLOWED",i.FILE_TOO_LARGE="FILE_TOO_LARGE",i.EXCEEDS_MAX_LIBRARY_SIZE="EXCEEDS_MAX_LIBRARY_SIZE",i.CORRUPTED_LIBRARY="CORRUPTED_LIBRARY",i.THUMBNAIL_NOT_AVAILABLE="THUMBNAIL_NOT_AVAILABLE",i.STALE_THUMBNAIL="STALE_THUMBNAIL",i.RENDITION_NOT_AVAILABLE="RENDITION_NOT_AVAILABLE",i.FS_ERROR="FS_ERROR",i.OUT_OF_SPACE="OUT_OF_SPACE",i.LOGGED_OUT="LOGGED_OUT",i.EXCEEDS_QUOTA="EXCEEDS_QUOTA",i.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",i.TRANSFER_ERROR="TRANSFER_ERROR",i.TRANSFER_ABORTED="TRANSFER_ABORTED",i.NETWORK_ERROR="NETWORK_ERROR",i.ACCESS_DENIED="ACCESS_DENIED",i.URL_VALIDATION_FAILED="URL_VALIDATION_FAILED",i.NO_COMPATIBLE_APP_FOUND="NO_COMPATIBLE_APP_FOUND",i.APP_LAUNCH_FAILED="APP_LAUNCH_FAILED",i.OPERATION_CANCELLED="OPERATION_CANCELLED",i.INVALID_DATA="INVALID_DATA",i.CLIENT_CONNECTION_ERROR="CLIENT_CONNECTION_ERROR",i.NOT_FOUND="NOT_FOUND",Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var o,r,a=n(20);o=n(21);var s={},c={"application/vnd.adobe.library+dcx":".cclibc"};s._setLogCallback=function(e){r=e},s.merge=function(e){var t,n;for(t=1;t<arguments.length;++t){var o=arguments[t];if("object"===i(o))for(n in o)o.hasOwnProperty(n)&&(e[n]=o[n])}return e},s.parentDirectory=function(e){var t=e.split("/");return t.pop(),t.join("/")},s.filePathComponents=function(e){var t=e.split("/"),n=t.pop(),i=n.split("."),o=i.length>1?i.pop():null;return{directory:t.join("/"),fileName:n,baseName:i.join("."),extension:o}},s.appendPathElements=function(){var e,t=[],n=arguments.length;for(e=0;e<n;e++){var i=arguments[e];"string"==typeof i&&""!==i&&(0===e&&1!==i.length||"/"===i.charAt(0)&&(i=i.slice(1)),e!==n-1&&"/"===i.charAt(i.length-1)&&(i=i.slice(0,i.length-1)),t.push(i))}return t.join("/")};var l=/^[^\u0000-\u001F\u0022\u002A\u003A\u003C\u003E\u003F\u005C\u007F]*[^\u0000-\u001F\u0022\u002A\u002E\u003A\u003C\u003E\u003F\u005C\u007F]{1}$/;s.isValidPath=function(e,t){try{if(e.length>65535)return!1;var n=(t?e.slice(1):e).split("/");if(!n||0===n.length)return!1;var i,o=n.length;for(i=0;i<o;i++)if(n[i].length>255||!l.test(n[i]))return!1;if(t&&n.length>0){var r=n[0];if("manifest"===r||"mimetype"===r)return!1}return!0}catch(e){return!1}},s.isValidAbsolutePath=function(e){return s.isValidPath(e,!0)};var u=s.noOp=function(){};s.consumeStream=function(e,t,n){e.on("data",n||u),e.on("end",t||u)},s.flatCopy=function(e){var t,n={},i=Object.keys(e),o=i.length;for(t=0;t<o;t++){var r=i[t];n[r]=e[r]}return n},s.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},s.objectsEqual=function(e,t,n){var o,r,a={},c=Object.keys(e),l=c.length;for(r=0;r<l;r++){if(o=c[r],!n||!n[o]){var u=e[o],h=t[o],p=i(u);if(p!==i(h))return!1;if("object"===p){if(!s.objectsEqual(u,h,n))return!1}else if(u!==h)return!1}a[o]=!0}for(l=(c=Object.keys(t)).length,r=0;r<l;r++)if(!a[o=c[r]])return!1;return!0};var h=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");s.parseURI=function(e){var t=e.match(h);return{scheme:t[2],authority:t[4],path:t[5],query:t[7],fragment:t[9]}},s.endPointOf=function(e){var t,n=s.parseURI(e),i=n.scheme,o=n.authority,r="https"===i?443:"http"===i?80:-1;return i&&o&&(t=(i+"://"+o).toLowerCase(),r>=0&&o.indexOf(":")<0&&(t=t+":"+r)),t},s.ensureRelativeHrefStartsWithSlash=function(e){if(e){var t=s.parseURI(e),n=t.scheme,i=t.authority;n||i||"/"!==e.charAt(0)&&(e="/"+e)}return e};var p=/^([^:]+):(.*)$/,d=/^\s+|\s+$/g;s.parseHeaders=function(e){var t,n,i,o={},r=e.split(/\r?\n/);for(t=0;t<r.length;++t){var a=r[t];if(a.length>0){var s=a.charCodeAt(0);if(!n||9!==s&&32!==s){var c=p.exec(a);c&&c.length>1&&(n=c[1].toLowerCase(),i=(i=c[2]||"").replace(d,""),o[n]?o[n]=o[n]+","+i:o[n]=i)}else o[n]=o[n]+" "+a.replace(d,"")}}return o},s.timeStamp=function(e){var t=(new Date).getTime();return e&&(t-=t%1e3),t},s.generateUuid=o,s.log=function(e){if("function"==typeof r)try{r(e)}catch(e){}},s.validateLinks=function(e){return void 0===e||Object(e)===e&&!Object.keys(e).some((function(t){var n=e[t];return"_expiry"===t?"number"!=typeof n:Array.isArray(n)?n.some((function(e){return"string"!=typeof e.href})):"string"!=typeof n.href}))},s.getTemplateFromLinks=function(e,t){var n=e&&e[t];if(n&&(!Array.isArray(n)||0!==n.length))return Array.isArray(n)&&(n=n[0]),n.href;s.log("Requested link is not available: ".concat(t))},s.getUrlFromLinks=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=s.getTemplateFromLinks(e,t);if(i){var o=new a(i);return o&&o.fill(n)}},s.getExtension=function(e){return c[e]||""},e.exports=s},function(e,t,n){var i=n(0),o=n(1),r={getErrorStatusCode:function(e){if(e)return e.code===i.UNEXPECTED_RESPONSE&&e.response&&e.response.statusCode||(e.underlyingError?r.getErrorStatusCode(e.underlyingError):void 0)},getSyncError:function(e,t,n){if(e){if(e.code===o.TRANSFER_ABORTED)return e;var a=r.getErrorStatusCode(e);return e.code===i.SERVICE_IS_INACTIVE?new o(o.LOGGED_OUT,"no access token: call updateAccessToken() and try again",t,e):e.code===i.NETWORK_ERROR?new o(o.NETWORK_ERROR,"error connecting to server",t,e):e.code===i.EXCEEDS_QUOTA?new o(o.EXCEEDS_QUOTA,"push failed due to insufficient remaining quota",t,e):e.code===i.OUT_OF_SPACE?new o(o.OUT_OF_SPACE,"not enough disk space",t,e):e.code===i.NOT_IMPLEMENTED?new o(o.NOT_IMPLEMENTED,"tried to call an API not implemented on the server",t,e):e.code===i.RETRYABLE_SERVER_ERROR?new o(o.RETRYABLE_SERVER_ERROR,"intermittent server failure - can retry later",t,e):e.code===i.INVALID_DATA||e.code===i.INVALID_JSON?new o(o.CORRUPTED_LIBRARY,"unable to read manifest",t,e):a&&n&&n[a]?new o(n[a],"server returned "+a+"response",t,e):new o(o.TRANSFER_ERROR,"something went wrong during a push/pull operation",t,e)}},getCommitError:function(e,t,n){if(e){var r=n?" - "+n:"";return e.code===i.INVALID_DATA||e.code===i.INVALID_JSON?new o(o.CORRUPTED_LIBRARY,"unable to read manifest"+r,t,e):e.code===i.OUT_OF_SPACE?new o(o.OUT_OF_SPACE,"not enough disk space"+r,t,e):new o(o.FS_ERROR,"filesystem error"+r,t,e)}},getFileSystemError:function(e,t,n){if(e)return"ENOSPC"===e.code?new o(o.OUT_OF_SPACE,t,n,e):new o(o.FS_ERROR,t,n,e)},getSnapshotError:function(e,t,n){if(e)return e.code===i.INVALID_DATA||e.code===i.INVALID_PARAMS?new o(o.INVALID_DATA,n,t,e):r.getFileSystemError(e,n,t)},getErrorPriority:function(e){var t=[o.OPERATION_CANCELLED,o.EXCEEDS_MAX_LIBRARY_SIZE,o.THUMBNAIL_NOT_AVAILABLE,o.RENDITION_NOT_AVAILABLE,o.URL_VALIDATION_FAILED,o.CORRUPTED_LIBRARY,o.TRANSFER_ABORTED,o.TRANSFER_ERROR,o.NETWORK_ERROR,o.EXCEEDS_QUOTA,o.RETRYABLE_SERVER_ERROR,o.LOGGED_OUT,o.FILE_TOO_LARGE,o.INVALID_DATA,o.FS_ERROR,o.OUT_OF_SPACE,o.ACCESS_DENIED,o.NOT_ALLOWED,o.DELETED_LOCALLY,o.REQUIRES_FILESYSTEM,o.NOT_SUPPORTED,o.NOT_IMPLEMENTED,o.INVALID_PARAMETER,o.READ_ONLY],n=e&&e.code&&t.indexOf(e.code);return void 0!==n?n:-1},errorToString:function(e){var t="";return e&&(e.message&&(t+=e.message),e.libraryId&&(t+=" library: "+e.libraryId),e.underlyingError?t+="\n<- "+r.errorToString(e.underlyingError):e.response&&e.response.statusCode&&(t+=": "+e.response.statusCode),e.failedComponents&&(t+="\n<- Failed Components:",e.failedComponents.forEach((function(e){var n=e.component&&e.component.id,i=e.error,o=i&&i.message,r=i&&i.response&&i.response.statusCode;t+="\n    ["+n+"] "+o+(r?": "+r:"")})))),t},isErrorCode:function(e){return!!e&&o.hasOwnProperty(e)&&o[e]===e}};Object.seal(r),e.exports=r},function(e,t){var n={constructStringFromTemplate:function(e,t){var n=e;return Object.keys(t).forEach((function(e){n=n.replace("{{"+e+"}}",t[e])})),n},parseLocalisationFile:function(e){for(var t={},n=e.split(/\n/),i=0;i<n.length;i++)if(n[i]=n[i].replace(/^\s\s*/,"").replace(/\s\s*$/,""),n[i].length>0&&"#"!==n[i].match("^#")){for(var o=n[i].split("="),r=o[0].replace(/^\s\s*/,"").replace(/\s\s*$/,""),a=1===o.length?"":o[1];a.match(/\\$/)&&"\\"===a.match(/\\$/).toString();)a=a.substring(0,a.length-1),a+=n[++i].replace(/\s\s*$/,"");for(var s=2;s<o.length;s++)a+="="+o[s];a=a.replace(/^\s\s*/,"").replace(/\s\s*$/,""),t[r]=a}return t},compareVersions:function(e,t){if(e=(e||"0").toString().replace(/(\.0)*$/,"").replace(/[^.0-9]+/gim,"."),t=(t||"0").toString().replace(/(\.0)*$/,"").replace(/[^.0-9]+/gim,"."),(isNaN(parseInt(e,10))||parseInt(e,10)>250)&&(e="0"),(isNaN(parseInt(t,10))||parseInt(t,10)>250)&&(t="0"),e===t)return 0;for(var n,i=e.split("."),o=t.split("."),r=0;r<i.length&&r<o.length;r++){if(n=parseInt(i[r],10)-parseInt(o[r],10),isNaN(n))return isNaN(parseInt(i[r],10))?1:-1;if(n>0)return-1;if(n<0)return 1}return(n=i.length-o.length)>0?-1:n<0?1:0},promisify:function(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return new Promise((function(t,i){e.apply(void 0,n.concat([function(e,n){return e?i(e):t(n)}]))}))}},debouncePromise:function(e,t){var n;return function(){for(var i=arguments.length,o=new Array(i),r=0;r<i;r++)o[r]=arguments[r];return new Promise((function(i,r){n&&clearTimeout(n),n=setTimeout((function(){t.apply(null,o).then(i,r),n=void 0}),e)}))}}},i={KCCC:"ACCC",KCCCADS:"ADCS",PHSP:"PHXS",SPRK:"SPKR",SPRKPR:"SPKR",SPRKDV:"SPKR"};n.normalizeProductCode=function(e){return i[e]||e},Object.seal(n),e.exports=n},function(e,t,n){var i,o=n(2),r={},a={canUseFileSystem:!1,_setFS:function(e){i=e,a.canUseFileSystem=!!e},ensureDirectoryExists:function(e,t){var n=function(e){e&&"EEXIST"===e.code?t():t(e)},r=function(r){if(r)t();else{var s=o.parentDirectory(e);s?a.ensureDirectoryExists(s,(function(o){o?t(o):i.mkdir(e,n)})):i.mkdir(e,n)}};e?i.exists(e,r):r(!0)},getTempFilePathAt:function(e,t){!function n(){var i=e+o.generateUuid();a.exists(i,(function(e){e?n():t(i)}))}()},exists:function(e,t){i.exists(e,t)},deleteFile:function(e,t){i.unlink(e,(function(e){e&&"ENOENT"!==e.code?t(e):t()}))},readFile:function(e,t,n){i.readFile(e,t,n)},writeFile:function(e,t,n,r){var s=o.parentDirectory(e);a.ensureDirectoryExists(s,(function(o){o?r(o):i.writeFile(e,t,n,r)}))},writeFileAtomically:function(e,t,n,r){var s=o.parentDirectory(e);a.ensureDirectoryExists(s,(function(o){o?r(o):a.getTempFilePathAt(s+"/",(function(o){i.writeFile(o,t,n,(function(t){t?r(t):i.rename(o,e,r)}))}))}))},createWriteStream:function(e,t){return i.createWriteStream(e,t)},createReadStream:function(e,t){return i.createReadStream(e,t)},move:function(e,t,n,r){var s=o.parentDirectory(t);a.ensureDirectoryExists(s,(function(o){if(o)r(o);else if(n){var a=(new Date).getTime()/1e3;i.utimes(e,a,a,(function(n){n?r(n):i.rename(e,t,r)}))}else i.rename(e,t,r)}))},info:function(e,t){i.stat(e,t)},directoryListing:function(e,t){var n,o,r=[],a=function(a){i.stat(e+"/"+a,(function(e,i){if(!e)try{r.push({name:a,info:i}),n--}catch(t){e=t}e?o||(o=e,t(e)):0===n&&t(void 0,r)}))};i.readdir(e,(function(e,i){if(!e)try{var o,r=i.length;for(n=r,o=0;o<r;o++)a(i[o])}catch(t){e=t}e?t(e):0===n&&t(void 0,[])}))},deleteDirectory:function(e,t){var n,o,r=function(){try{i.rmdir(e,t)}catch(e){t(e)}},s=function(e){e&&!n&&(n=e),--o<1&&(n?t(n):r())},c=function(t){var n=e+"/"+t;i.unlink(n,(function(e){try{e?a.deleteDirectory(n,(function(e){s(e)})):s()}catch(e){s(e)}}))};i.readdir(e,(function(e,n){if(!e)try{var i,a=n.length;if(a<1)r();else for(o=a,i=0;i<a;i++)c(n[i])}catch(t){e=t}e&&t(e)}))}};a.copyFile=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return r[t]=r[t]||{operationsInFlight:0,queue:[]},function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];var s=o.pop(),c=function(){r[t].operationsInFlight+=1,e.apply(void 0,o.concat([function(){r[t].operationsInFlight-=1,r[t].queue.length>0&&r[t].queue.shift()(),s.apply(void 0,arguments)}]))};if(r[t].operationsInFlight>=n)return r[t].queue.push(c);c()}}((function(e,t,n){var r=o.parentDirectory(t);a.ensureDirectoryExists(r,(function(r){r?n(r):function(e,t,n){var r=t+o.generateUuid();i.copyFile(e,r,(function(e){e?n(e):i.rename(r,t,n)}))}(e,t,n)}))})),a.getMD5Hash=function(e,t){var n=(void 0).createHash("md5").setEncoding("base64");try{var o=i.createReadStream(e);o.pipe(n).on("finish",(function(){return t(null,n.read())})),o.on("error",(function(e){return t(e)}))}catch(e){t(e)}},e.exports=a},function(e,t,n){var i=n(11),o=n(0),r=n(16),a=n(1),s=n(4).promisify,c={},l={};c.isCompatibleType=function(e,t){return e===t||e===l[t]},c.validateLibraryId=function(e,t){if(t){if(e&&e.length>=30&&e.match(/^[0-9A-Z-]+$/i))return!0}else if(e&&e.match(/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i))return!0;return!1},c.areManifestsEqual=function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;var n=JSON.parse(e),i=JSON.parse(t);delete n["manifest-format-version"],delete i["manifest-format-version"];try{if(JSON.stringify(n)===JSON.stringify(i))return!0}catch(e){}return!1},c.getManifestForComparison=function(e,t){return t&&"\n"===t[1]?e._dcxBranch.prettifiedLocalData:e._dcxBranch.localData},c.getDCXKey=function(e,t){if(!e||!("string"==typeof e||e instanceof String)||""===e)throw new a(a.INVALID_PARAMETER,"Invalid namespace");if(!t||!("string"==typeof t||t instanceof String)||""===t)throw new a(a.INVALID_PARAMETER,"Invalid key");return e+"#"+t},c.getCustomDCXData=function(e){var t=e.getCustomKeys(),n=[];return t.forEach((function(t){var i=t.split("#"),o=i.length>=2;o&&i.forEach((function(e){""===e&&(o=!1)}));var a=0===t.indexOf(r.DL_PREFIX);o&&!a&&n.push({namespace:i.shift(),key:i.join("#"),value:e.getValue(t)})})),n},c.copyCustomDCXData=function(e,t){c.getCustomDCXData(e).forEach((function(e){t.setValue(c.getDCXKey(e.namespace,e.key),e.value)})),[r.REPRESENTATION_ORDER_KEY,r.IS_PREFERRED_THUMBNAIL_KEY,r.SHA_KEY].forEach((function(n){var i=e.getValue(n);i&&t.setValue(n,i)}))},c.checkDeletedState=function(e,t){if(e.isDeletedLocally){if(t)return t(new a(a.DELETED_LOCALLY,"deleted/orphan object")),!0;throw new a(a.DELETED_LOCALLY,"deleted/orphan object")}return!1},c.checkEncoding=function(e,t,n){if(-1===t.indexOf(e)){var i=t.join(", ");return n(new a(a.INVALID_PARAMETER,"Unsupported encoding. Supported encodings are: "+i)),!1}return!0},c.sortRepresentations=function(e){if(!(e.length<2))for(var t=!0;t;){t=!1;for(var n=1;n<e.length;n++){var i=e[n-1],o=e[n];o._getOrder()<i._getOrder()&&(e[n-1]=o,e[n]=i,t=!0)}}},c.removeMissingComponents=function(e,t,n){if(t&&n){var i=0,o=0;return n.forEach((function(n){var r=n.component,a=n.error;r&&a&&a.response&&404===a.response.statusCode&&(t.removeComponent(r),i++,e._services.log("Removed missing component: "+r.id+" from library "+t.compositeId)),r&&a&&"[UNEXPECTED_RESPONSE] Incorrect content length"===a.message&&(o++,e._services.log("Skipped length-mismatch component: "+r.id+" from library "+t.compositeId))})),e._services.log("Fixed "+i+" of "+n.length+" components that failed to download"),e._analytics.reportRemoveMissingComponents(t.compositeId,n,i),n.length===i+o?t:void 0}};var u=function(e,t){var n=function(e){return e.getRepresentationById(t)},i=e.elements.find(n)||e.removedElements.find(n);return i&&n(i)},h={"model/vnd.adobe.dn+dcx":"model/vnd.adobe.dn+dcxucf","application/vnd.adobe.element.agc+dcx":"application/vnd.adobe.element.agc+json"};c.fixLocalComponents=function(e,t){if(e&&t){var n=0,i=[];t.forEach((function(t){var r=t.component,a=t.error;if(r&&a&&a.code===o.INVALID_STATE){var s=u(e,r.id);s?i.push(s):e._dcxBranch.removeComponent(r),n++,e._services.log("Removed missing local component: ".concat(r.id," from library ").concat(e.id))}else if(r&&a&&h[r.type]){var c=u(e,r.id),l=h[r.type];c&&(c._getDCXElement().type=l,n++,e._services.log("Fixed mime type of local component: ".concat(r.id," from library ").concat(e.id," (").concat(l,")")))}})),n>0&&(e._beginOperation(),i.forEach((function(e){e.element.removeRepresentation(e)})),e._endOperation()),e._services.log("Fixed "+n+" of "+t.length+" components that failed to upload")}},c.recoverReadOnlyEdits=function(e,t,n){var i=[];e.elements.forEach((function(e){var n=t&&t.getChildWithId(e.id);(n&&n.getValue(r.MODIFIED_KEY))!==e.modified&&i.push(e)}));var o=[];if(i.length>0){var a,c=e._localisation.translate("LIBS_RECOVERED_LIBRARY",{name:e.name});e.collection._privateCollection.libraries.some((function(t){if(t.name===c&&t.isWritable&&t.elements.length<e._config.MAX_ELEMENTS)return a=t,!0})),a||(a=e.collection._privateCollection.createLibrary(c));var l=s(e.copyElement.bind(e));i.forEach((function(e){return o.push(l(e,a))})),e._services.log("Recovering "+i.length+" elements from read-only library")}Promise.all(o).then((function(){return n(null)}),(function(e){return n(e)}))},c.ensureBranchDataValid=function(e){var t=[r.ELEMENTS_NAME,r.REMOVED_ELEMENTS_NAME],n=!1;return e.getChildrenOf().forEach((function(i){if(-1!==t.indexOf(i.name)){var o=i.name===r.REMOVED_ELEMENTS_NAME;e.getChildrenOf(i).forEach((function(e){var t=e.getValue(r.REMOVED_KEY);!o&&t?(e.removeValue(r.REMOVED_KEY),n=!0):o&&!t&&(e.setValue(r.REMOVED_KEY,Date.now()),n=!0)}))}})),n},c.collaborationStateToDCX=function(e){return"incoming"===e?i.COLLABORATION.SHARED_WITH_USER:"outgoing"===e?i.COLLABORATION.SHARED_BY_USER:i.COLLABORATION.PRIVATE},c.collaborationStateFromDCX=function(e){return e===i.COLLABORATION.SHARED_WITH_USER?"incoming":e===i.COLLABORATION.SHARED_BY_USER?"outgoing":void 0},c.getCompositeRenditionMap=function(e){var t=e.getComponentsOf(),n={};return t&&t.forEach((function(e){if("rendition"===e.relationship){var t=e.getValue(r.RENDITION_TYPE_KEY);t&&(n[t]=e)}})),n},c.recoverFromElmo=function(e,t,n){var i=e._services.fs,o=e._services.getPathSeparator(),r={},a=t.every((function(t){r[t]=!0;var n=e._getCompositeDir(t)+o+"manifest";try{var a=JSON.parse(i.readFileSync(n,"utf8")).children.find((function(e){return"elements"===e.name}));if(!a.children||0===a.children.length)return!0}catch(e){}})),s=e._syncManager,c=function(t){if(t)return s.links.test(e._getNewCompositeHref(t),n),void e._services.log("Failed to recover from ELMO: "+t);e._services.log("Successfully recovered from ELMO"),n()};if(!a)return c("has_data");var l=function(){e._services.fileUtils.recursiveDeleteDirectory(e._getBaseDir(),(function(e){c(e&&"local_delete")}))};s.getServerComposites(e,(function(t,n){if(t)return c("sg_fetch");n.every((function(e){return r[e.name]}))&&n.length>=e._config.ELMO_LOCAL_LIBRARY_LIMIT?s.deleteAllServerComposites(e,(function(e){if(e)return c("sg_delete");l()})):n.length<e._config.ELMO_SERVER_RECOVERED_LIMIT?l():c("out_of_sync")}))},Object.seal(c),e.exports=c},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(1),r=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._restrictedTypes=t,this._logCallback=n,this._listeners={}}var t,n;return t=e,(n=[{key:"_log",value:function(e){this._logCallback&&this._logCallback(e)}},{key:"_checkType",value:function(e){if(this._restrictedTypes&&!this._restrictedTypes.includes(e)){var t="".concat(e," is not allowed. Should be one of: [").concat(this._restrictedTypes.join(", "),"]");throw new o(o.INVALID_PARAMETER,t)}}},{key:"add",value:function(e,t){this._checkType(e),this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t)}},{key:"remove",value:function(e,t){this._checkType(e);var n=this._listeners[e],i=n?n.indexOf(t):-1;-1!==i&&n.splice(i,1)}},{key:"removeAll",value:function(e){e?(this._checkType(e),delete this._listeners[e]):this._listeners={}}},{key:"notify",value:function(e,t){var n=this;this._checkType(e);var i=this._listeners[e];i&&i.slice().forEach((function(e){try{e.apply(void 0,t||[])}catch(e){n._log("Error in listener callback: "+(e?e.toString():"")),e&&e.stack&&n._log(e.stack)}}))}},{key:"hasListeners",value:function(e){return this._checkType(e),(this._listeners[e]||[]).length>0}},{key:"forEach",value:function(e){var t=this._listeners;Object.keys(t).forEach((function(n){t[n].forEach((function(t){return e(n,t)}))}))}}])&&i(t.prototype,n),e}();e.exports=r},function(e,t){e.exports={PRIMARY:"http://ns.adobe.com/adobecloud/rel/primary",ID:"http://ns.adobe.com/adobecloud/rel/id",PATH:"http://ns.adobe.com/adobecloud/rel/path",RENDITION:"http://ns.adobe.com/adobecloud/rel/rendition",MANIFEST:"http://ns.adobe.com/adobecloud/rel/manifest",COMPONENT:"http://ns.adobe.com/adobecloud/rel/component",PAGE:"http://ns.adobe.com/adobecloud/rel/page",DISCARD:"http://ns.adobe.com/adobecloud/rel/discard",DIRECTORY:"http://ns.adobe.com/adobecloud/rel/directory",AC_EFFECTIVE:"http://ns.adobe.com/adobecloud/rel/ac/effective",AC_POLICY:"http://ns.adobe.com/adobecloud/rel/ac/policy",CREATE:"http://ns.adobe.com/adobecloud/rel/create",METADATA:"http://ns.adobe.com/adobecloud/rel/metadata/repository",REPOSITORY:"http://ns.adobe.com/adobecloud/rel/repository",RESOLVE_ID:"http://ns.adobe.com/adobecloud/rel/resolve/id",RESOLVE_PATH:"http://ns.adobe.com/adobecloud/rel/resolve/path",OPS:"http://ns.adobe.com/adobecloud/rel/ops",BLOCK_INITIALIZE:"http://ns.adobe.com/adobecloud/rel/block/init",BLOCK_TRANSFER:"http://ns.adobe.com/adobecloud/rel/block/transfer",BLOCK_FINALIZE:"http://ns.adobe.com/adobecloud/rel/block/finalize",APP_METADATA:"http://ns.adobe.com/adobecloud/rel/metadata/application",EMBEDDED_METADATA:"http://ns.adobe.com/adobecloud/rel/metadata/embedded",ANNOTATIONS:"http://ns.adobe.com/adobecloud/rel/annotations",DESCRIBED_BY:"describedBy"}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._isLocked=!1,this._queue=[]}var t,i;return t=e,(i=[{key:"execute",value:function(e){var t=this,n=function(e){return t.release(),e};return this.obtain().then(e).then((function(e){return n(e)}),(function(e){return n(Promise.reject(e))}))}},{key:"_obtain",value:function(e){this._isLocked?this._queue.push(e):(this._isLocked=!0,e(null))}},{key:"obtain",value:function(e){var t=this;return e?this._obtain(e):new Promise((function(e,n){return t._obtain((function(t){return t?n(t):e()}))}))}},{key:"release",value:function(){if(this._queue.length>0){var e=this._queue.shift();setTimeout((function(){return e(null)}))}else this._isLocked=!1}},{key:"abortPendingOperations",value:function(e){var t=this._queue;this._queue=[],t.forEach((function(t){return t(e)}))}},{key:"isLocked",value:function(){return this._isLocked}},{key:"hasPendingRequest",value:function(){return this._queue.length>0}}])&&n(t.prototype,i),e}();e.exports=i},function(e,t){var n={},i={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/illustrator":["ai"],"application/illustrator-text":["ai"],"application/illustrator.template":["ait"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/photoshop":["psd"],"application/photoshop.large":["psb"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.ae.graphic+zip":["aegraphic","mogrt"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.animate-xfl+zip":["fla","xfl"],"application/vnd.adobe.animate-oam+zip":["oam"],"application/vnd.adobe.animate-sym+zip":["sym"],"application/vnd.adobe.animate-swf+zip":["swa"],"application/vnd.adobe.characterstyle+json":["style"],"application/vnd.adobe.characterstyle+snippet":["idms"],"application/vnd.adobe.charts+zip":["zip"],"application/vnd.adobe.ch.puppet+zip":["puppet"],"application/vnd.adobe.color+json":["ase"],"application/vnd.adobe.colortheme+json":["ase"],"application/vnd.adobe.cube+txt":["cube"],"application/vnd.adobe.element.agc+json":["agc"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.ibl.light+zip":["zip"],"application/vnd.adobe.illustrator.template":["ait"],"application/vnd.adobe.indesign-idms":["idms"],"application/vnd.adobe.indesign-idms-text":["idms"],"application/vnd.adobe.indesign.template":["indt"],"application/vnd.adobe.layerstyle":["asl"],"application/vnd.adobe.look+xml":["look"],"application/vnd.adobe.graphic+json":["json"],"application/vnd.adobe.mdl.material+zip":["zip"],"application/vnd.adobe.muse-collection":["muse"],"application/vnd.adobe.obj.3d+zip":["zip"],"application/vnd.adobe.paragraphstyle+json":["style"],"application/vnd.adobe.paragraphstyle+snippet":["idms"],"application/vnd.adobe.photoshop.template":["psdt"],"application/vnd.adobe.ppro.graphic+zip":["prgraphic","mogrt"],"application/vnd.adobe.ribbon.brush+zip":["brush"],"application/vnd.adobe.scatter.brush+zip":["brush"],"application/vnd.adobe.vector.brush+zip":["brush"],"application/vnd.adobe.text+json":["text-json"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/font-woff":["woff"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/aif":["aif"],"audio/basic":["au","snd"],"audio/m4a":["m4a"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a"],"audio/mpeg":["mpga","mp2","mp2a","m2a"],"audio/mpeg3":["mp3","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/wav":["wav"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dng":["dng"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heif":["heif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/jpg":["jpg"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.adobe.photoshop.template":["psdt"],"image/vnd.adobe.pattern+png":["png"],"image/vnd.adobe.shape+svg":["shape"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-adobe-dng":["dng"],"image/x-adobe-photoshop-brush":["abr"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.adobe.dn+dcx":["dn"],"model/vnd.adobe.dn+dcxucf":["dn"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache"],"text/calendar":["ics","ifb"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-fortran":["f","for","f77","f90"],"text/x-java-source":["java"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-nfo":["nfo"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["mov","qt"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx","wmv"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-quicktime":["mov"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]},o={};Object.keys(i).forEach((function(e){i[e].forEach((function(t){o[t]=o[t]||[],o[t].push(e)}))})),n.getExtensions=function(e){return e?i[e.toLowerCase()]||((t=e.toLowerCase().match(/application\/x-adobe-libraries-(.+)/))?[t[1]]:[]):[];var t},n.getMimeTypes=function(e){return e?o[e.toLowerCase()]||function(e){return["application/x-adobe-libraries-"+e]}(e.toLowerCase()):[]},Object.seal(n),e.exports=n},function(e,t,n){var i=n(12),o=n(52),r=n(57),a=n(60),s=n(26),c=n(27),l=n(2),u=n(0),h=n(5),p=n(28),d=n(14),_=n(23);function f(e,t){e&&h._setFS(e),this._compositeOptions=l.merge({},t),t&&t.logCallback&&l._setLogCallback(t.logCallback)}f.COLLABORATION={PRIVATE:i.COLLABORATION.PRIVATE,SHARED_BY_USER:i.COLLABORATION.SHARED_BY_USER,SHARED_WITH_USER:i.COLLABORATION.SHARED_WITH_USER},f.AdobeDCXError=u,f.FileContent=d,f.StreamProvider=_,f.prototype.newEmptyComposite=function(e,t,n,o){var r=new i(e,t,null,o,null,this._compositeOptions);return n&&(r.path=n),r},f.prototype.newCompositeFromLocalStorage=function(e,t){try{if("string"!=typeof e)throw new u(u.INVALID_PARAMS,"");var n=new i(null,null,e,null,null,this._compositeOptions);n.loadCurrentFromLocalStorage((function(e){t(e,e?void 0:n)})),n.deleteTempFiles()}catch(e){t(e)}},f.prototype.newCompositeWithHref=function(e,t,n,o,r){var a=new i(n,r,null,o,e,this._compositeOptions);return t&&(a.path=t),a},f.prototype.newCompositeAsCopyOf=function(e,t,n,o,r,a){return i.newCompositeAsCopyOf(e,t,n,o,r,a,this._compositeOptions)},f.prototype.copyCompositeAndAssetsFrom=function(e,t,n,o,r,a,s){i.copyCompositeAndAssetsFrom(e,t,n,o,r,a,this._compositeOptions,s)},f.prototype.createHTTPService=function(e){return new o(e)},f.prototype.createStorageSession=function(e,t,n,i){return new r(e,t,n,i)},f.prototype.createCommunitySession=function(e,t,n){return new a(e,t,n)},f.prototype.createPlatformSession=function(e,t,n,i){return new s(e,t,n,i)},f.prototype.compositeXfer=c,f.prototype.snapshot=p,e.exports=f},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var o=n(0),r=n(13),a=n(22),s=n(50),c=n(15).STATES,l=n(5),u=n(2),h={PRIVATE:void 0,SHARED_BY_USER:"sharedByUser",SHARED_WITH_USER:"sharedWithUser"};function p(e,t,n,i,o,a){o=u.ensureRelativeHrefStartsWithSlash(o),this._options=a||{},n?this._setPath(n):o?(this._href=o,this._options.links&&(this._links=this._options.links),this._options.assetId&&(this._assetId=this._options.assetId),e&&(this._name=e),t&&(this._type=t),i&&(this._id=i)):t&&(this._current=new r,e&&(this._current._data.name=e),this._current._data.type=t,i&&(this._current.compositeId=i)),this._autoRemoveUnusedLocalFiles=!0,this._options.xhrBaseBranchSupport&&(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0),this._collaborationType=h.PRIVATE}function d(e,t,n){return{get:function(){return this._current?this._current[t]:this[e]},set:function(r){if(!n.includes(i(r)))throw new o(o.INVALID_PARAMS,"Expected types: ".concat(n.join(", ")));this._current&&(this._current[t]=r),this[e]=r}}}p.newCompositeAsCopyOf=function(e,t,n,i,a,s,c){var l=e._core;if(l||e.current&&(l=e.current._core),!l)throw new o(o.INVALID_PARAMS,"compositeBranchOrElement must be a branch, an element or a composite with a current branch.");var h=new p(void 0,void 0,void 0,void 0,void 0,c);return i&&(h.path=i),h._current=r._newBranchAsCopyOfCore(l,this._localStorage),h.id=a||u.generateUuid(),t&&(h.name=t),n&&(h.type=n),s&&(h.href=s),c&&c.links&&(h.links=c.links),c&&c.assetId&&(h.assetId=c.assetId),h},p.copyCompositeAndAssetsFrom=function(e,t,n,i,a,c,l,d){var _=e._core;if(_||e.current&&(_=e.current._core),!_)throw new o(o.INVALID_PARAMS,"compositeBranchOrElement must be a branch, an element or a composite with a current branch.");var f=new p(void 0,void 0,void 0,void 0,void 0,l);i&&(f.path=i),r._newBranchAsCopyOfCoreWithAssets(_,f.path&&new s(f.path,l.preserveFileExtensions),(function(e,i){if(e)return d(e);f._current=i,f.collaborationType=h.PRIVATE,a!==f.id&&(f.id=a||u.generateUuid()),t&&(f.name=t),n&&(f.type=n),c&&(f.href=c),d(null,f)}))},p.COLLABORATION=h,Object.defineProperties(p.prototype,{id:d("_id","compositeId",["string"]),name:d("_name","name",["string"]),type:d("_type","type",["string"]),href:{get:function(){return this._current?this._current.compositeHref:this._href},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");e=u.ensureRelativeHrefStartsWithSlash(e),this._current&&(this._current.compositeHref=e),this._href=e}},links:d("_links","compositeLinks",["object"]),assetId:d("_assetId","compositeAssetId",["string"]),repoMetadata:d("_repoMetadata","compositeRepoMetadata",["object"]),isWritable:d("_isWritable","compositeIsWritable",["boolean"]),parentAssetId:d("_parentAssetId","compositeParentAssetId",["string"]),isParentWritable:d("_isParentWritable","compositeIsParentWritable",["boolean"]),isRenamePending:d("_isRenamePending","compositeIsRenamePending",["boolean"]),storageAssignee:d("_storageAssignee","compositeStorageAssignee",["object"]),collaborationType:{get:function(){return this._current?this._current._collaborationType:this._collaborationType},set:function(e){if(e!==h.PRIVATE&&e!==h.SHARED_BY_USER&&e!==h.SHARED_WITH_USER)throw new o(o.INVALID_PARAMS,"Invalid value: ."+e);this._current&&(this._current._collaborationType=e),this._collaborationType=e}},clientDataString:{get:function(){return this._current?this._current._clientDataString:this._clientDataString},set:function(e){if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Invalid clientDataString: must be a string or undefined.");var t=this._options.maxClientDataLength||1024;if(e&&e.length>t)throw new o(o.INVALID_PARAMS,"Invalid clientDataString: cannot be greater than 1KB");this._current&&(this._current._clientDataString=e),this._clientDataString=e}},path:{get:function(){return this._path},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._setPath(e)}},isBound:{get:function(){return this._current&&this._current.isBound||!this._current&&this._href},set:function(){throw new o(o.READ_ONLY,"Cannot set the property isBound. Use resetIdentity or resetBinding instead.")}},hasLocalStorage:{get:function(){return this._localStorage},set:function(){throw new o(o.READ_ONLY,"Cannot set the property hasLocalStorage.")}},autoRemoveUnusedLocalFiles:{get:function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._autoRemoveUnusedLocalFiles},set:function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._autoRemoveUnusedLocalFiles=e}},clientDataStoragePath:{get:function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.clientDataPath()},set:function(){throw new o(o.READ_ONLY,'Property "clientDataStoragePath" is read-only.')}},current:{get:function(){return this._current},set:function(){throw new o(o.READ_ONLY,'Property "current" is read-only.')}}}),p.prototype.loadCurrentFromLocalStorage=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._loadBranch(this._localStorage.currentManifestPath(),!1,(function(n,i){if(!n&&i)try{t._current=i,t._currentBranchCommittedAtDate=u.timeStamp(!0)}catch(e){n=e}e(n,n?void 0:i)}))},p.prototype.commitChanges=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!this._current)return e(new o(o.INVALID_STATE,"Current branch is not in memory."));var t=this;l.writeFileAtomically(this._localStorage.currentManifestPath(),this._current.localData,"utf8",(function(n){if(!n)try{t._currentBranchCommittedAtDate=u.timeStamp(!0),t._current._isDirty=!1}catch(e){n=e}e(n)}))},p.prototype.tempAssetPath=function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.tempPathForComponent()},p.prototype.deleteTempFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.deleteTempFiles((function(t){e&&e(t)}))},p.prototype.removeUnusedLocalFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.removeUnusedLocalFiles(this._currentBranchCommittedAtDate,e)},p.prototype.removeLocalFilesForComponentsWithIDs=function(e,t){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new o(o.INVALID_PARAMS,"Param componentIds must not be nil.");var n=this,i=this._current;n._loadBranch(n._localStorage.currentManifestPath(),!0,(function(r,a){r&&"ENOENT"!==r.code?t([r]):n.loadBaseBranch((function(r,s){if(r&&"ENOENT"!==r.code)t([r]);else{var u,h,p=[],d={};for(u=0;u<e.length;++u){var _=e[u],f=i.getComponentWithId(_),m=a?a.getComponentWithId(_):void 0,v=s?s.getComponentWithId(_):void 0;if(!(f&&"/META-INF/metadata.xml"===f.absolutePath||m&&"/META-INF/metadata.xml"===m.absolutePath||v&&"/META-INF/metadata.xml"===v.absolutePath))if(f&&f.state===c.modified||m&&m.state===c.modified){var y=new o(o.COMPONENT_MODIFIED_ERROR,"Cannot remove the file of a modified component.");y.componentId=_,p.push(y)}else f&&(h=i.assetOfComponent(f))&&(void 0===d[h]&&(d[h]=_),n._localStorage.removeComponentAsset(f,i._local()),i._setDirty(!0)),m&&(h=a.assetOfComponent(m))&&void 0===d[h]&&(d[h]=_),v&&(h=s.assetOfComponent(v))&&void 0===d[h]&&(d[h]=_)}var g=Object.keys(d),E=g.length;if(E>0){var O=function(e){l.deleteFile(e,(function(n){n&&(n.componentId=d[e],p.push(n)),0==--E&&t(p.length>0?p:void 0)}))};for(u=0;u<g.length;++u)O(g[u])}else t(p.length>0?p:void 0)}}))}))},p.prototype.removeLocalStorage=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!this._path)return e(new o(o.INVALID_STATE,"No path set."));l.deleteDirectory(this._path,e)},p.prototype.loadBaseBranch=function(e){if(!this._localStorage&&!this._baseBranchData)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(this._localStorage)this._loadBranch(this._localStorage.currentBaseManifestPath(),!0,e);else{var t,n;try{n=new r(void 0,!0).parse(this._baseBranchData)}catch(e){t=e}e(t,n)}},p.prototype.loadPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pulledManifestPath(),!1,e)},p.prototype.loadPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pushedManifestPath(),!1,e)},p.prototype.resolvePullWithBranch=function(e,t){if(!e)throw new o(o.INVALID_PARAMS,"Need a branch.");if(e===this._current)throw new o(o.INVALID_PARAMS,"Cannot resolve current.");if(this._localStorage&&!t)throw new o(o.INVALID_PARAMS,"Need a callback function.");var n=this,i=function(){e.readOnly=!1,e._collaborationType=n.collaborationType,e._clientDataString=n.clientDataString,n._current=e};if(this._localStorage)n._localStorage.resolvePulledBranch(e,(function(e){if(!e)try{i(),n._autoRemoveUnusedLocalFiles&&n._localStorage.removeUnusedLocalFiles(n._currentBranchCommittedAtDate,(function(){}))}catch(t){e=t}t(e,e?void 0:n._current)}));else{if(this._options.xhrBaseBranchSupport&&(this._baseBranchData=this._pulledBranchData,this._pulledBranchData=void 0),i(),!t)return this._current;t(void 0,this._current)}},p.prototype.acceptPush=function(e){if(this._localStorage&&!e)throw new o(o.INVALID_PARAMS,"Need a callback function.");var t,n,i=this,r=function(o){if(!o)if(t)try{i._localStorage?(t.applyToBranch(n),i._localStorage.acceptPushedBranch(n,(function(n){if(!n)try{t.applyToBranch(i._current,!0),i._autoRemoveUnusedLocalFiles&&i._localStorage.removeUnusedLocalFiles(i._currentBranchCommittedAtDate,(function(){}))}catch(e){n=e}e(n)}))):(t.applyToBranch(i._current,!0),i._options.xhrBaseBranchSupport&&(i._baseBranchData=i._pushedBranchData,i._pushedBranchData=void 0),i._pushJournal=void 0,e&&e())}catch(e){o=e}else e&&e();if(o){if(!e)throw o;e(o)}};if(!this._localStorage)return t=this._pushJournal,r();var s,c=2;a.readJournal(i._localStorage.pushJournalPath(),i,!1,(function(e,n){c--,s?r():(e?"ENOENT"!==e.code&&(s=new o(o.INVALID_STATE,"Failed to load push journal.",e)):t=n,c||r())})),this._loadBranch(this._localStorage.currentManifestPath(),!1,(function(e,t){c--,s?r():(e?s=new o(o.INVALID_STATE,"Failed to load current manifest.",e):n=t,c||r())}))},p.prototype.discardPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPulledBranch((function(n){if(!n){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,(function(){}))}catch(e){n=e}e(n)}n&&e(n)}))},p.prototype.discardPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPushedBranch((function(n){if(!n){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,(function(){}))}catch(e){n=e}e(n)}n&&e(n)}))},p.prototype.resetBinding=function(e){delete this._href,this._current&&this._current._resetBinding(),this._localStorage?this._discardEveryBranchButCurrent(e):(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0,e&&e())},p.prototype.resetIdentity=function(e){delete this._href,this._current?(this._current._resetIdentity(),this._id=this._current.compositeId):this._id=u.generateUuid(),this._localStorage?this._discardEveryBranchButCurrent(e):(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0,e&&e())},p.prototype.setLocalData=function(e,t){if(!this._current)throw new o(o.INVALID_STATE,"No current branch set.");this._current.setLocalData(e,t)},p.prototype.getLocalData=function(e){if(!this._current)throw new o(o.INVALID_STATE,"No current branch set.");return this._current.getLocalData(e)},p.prototype._loadBranch=function(e,t,n){if("function"!=typeof n)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');var i=this;l.exists(e,(function(o){o?l.readFile(e,"utf8",(function(o,a){var s;if(!o)try{(s=new r(void 0,t,e).parse(a))._localStorage=i._localStorage}catch(e){o=e}n(o,s)})):n()}))},p.prototype._discardEveryBranchButCurrent=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t,n=this,i=3,r=function(o){o&&!t&&(t=o),0==--i&&(!t&&n._autoRemoveUnusedLocalFiles&&n._localStorage.removeUnusedLocalFiles(n._currentBranchCommittedAtDate,(function(){})),e(t))};this._localStorage.discardPushedBranch(r),this._localStorage.discardPulledBranch(r),this._localStorage.discardBaseBranch(r)},p.prototype._setPath=function(e){this._localStorage?this._localStorage.compositePath=e:l.canUseFileSystem&&(this._localStorage=new s(e,this._options.preserveFileExtensions),this._current&&(this._current._localStorage=this._localStorage)),this._path=e},e.exports=p},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var r=n(19),a=n(49),s=n(0),c=n(2);function l(e,t,n){e?e=this._setData(e,t):(e={"manifest-format-version":6,id:c.generateUuid()},this.originalManifestFormatVersion=6,this._core=new r(e,this,t),this._data=e),this._pendingElements=[],this.manifestPath=n}function u(e,t){return{get:function(){return this._data.local?this._data.local[e]:void 0},set:function(n){var o=this._core;if(o._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if(!t.includes(i(n)))throw new s(s.INVALID_PARAMS,"Expected types: ".concat(t.join(", ")));o._local()[e]=n,o._setDirty(!0)}}}l._newBranchAsCopyOfCore=function(e,t){var n=new l(JSON.parse(JSON.stringify(e._data))),i=n._core;return n._localStorage=t,n._resetIdentity((function(n){var o=e.getComponentWithId(n.id);if(!o)throw new s(s.INVALID_STATE,"Could not find original component.");if("modified"===o.state||!o.etag)throw new s(s.INVALID_STATE,"Cannot create a new composite from a branch that contains modified or unbound components.");var r=e._getHrefOfComponent(o);if(!r)throw new s(s.INVALID_STATE,"Cannot determine the href of component id "+o.id);i._setSourceHrefOfComponent(r,n),t&&t.removeComponentAsset(n,i._local())})),n},l._newBranchAsCopyOfCoreWithAssets=function(e,t,n){var i=JSON.parse(JSON.stringify(e._data));i.children=[],i.components=[];var r=new l(i);r._localStorage=t,r._resetBinding();var a=e.getChildrenOf().map((function(e){return new Promise((function(t,n){r.copyChild(e,r.rootNode,void 0,void 0,void 0,(function(e){return e?n(e):t()}))}))})),s=e.getComponentsOf().map((function(e){return new Promise((function(t,n){r.copyComponent(e,r.rootNode,void 0,void 0,(function(e){return e?n(e):t()}))}))}));Promise.all([].concat(o(a),o(s))).then((function(){r._reset(!0),n(null,r)}),n)},Object.defineProperties(l.prototype,{compositeId:{get:function(){return this._core.rootNode.id},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new s(s.INVALID_PARAMS,"Expecting a non-empty string.");if(t._allNodes[e])throw new s(s.DUPLICATE_VALUE,"There is already a node with the same id.");delete t._allNodes[this._data.id],this._data.id=e,t._allNodes[e]=this._core.rootNode,t._setDirty()}},rootNode:{get:function(){return this._core.rootNode},set:function(e){this._core.rootNode=e}},name:{get:function(){return this._core.rootNode.name},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new s(s.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get:function(){return this._core.rootNode.type},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new s(s.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get:function(){return this._data.local?this._data.local.compositeHref:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new s(s.INVALID_PARAMS,"Expecting a string or undefined.");t._local().compositeHref=c.ensureRelativeHrefStartsWithSlash(e),t._setDirty(!0)}},compositeLinks:{get:function(){return this._data.local?this._data.local.links:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if(!c.validateLinks(e))throw new s(s.INVALID_PARAMS,"Expecting an object or undefined.");t._local().links=e,t._setDirty(!0)}},compositeAssetId:u("assetId",["string","undefined"]),compositeRepoMetadata:u("repoMetadata",["object","undefined"]),compositeIsWritable:u("isWritable",["boolean","undefined"]),compositeParentAssetId:u("parentAssetId",["string","undefined"]),compositeIsParentWritable:u("isParentWritable",["boolean","undefined"]),compositeIsRenamePending:u("isRenamePending",["boolean","undefined"]),compositeStorageAssignee:u("storageAssignee",["object","undefined"]),_collaborationType:{get:function(){return this._data.local?this._data.local.collaborationType:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");e?t._local().collaborationType=e:delete t._local().collaborationType,t._setDirty(!0)}},_clientDataString:{get:function(){return this._data.local?this._data.local.clientDataString:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");e?t._local().clientDataString=e:delete t._local().clientDataString,t._setDirty(!0)}},manifestEtag:{get:function(){return this._data.local?this._data.local.manifestEtag:void 0},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new s(s.INVALID_PARAMS,"Expecting a string or undefined.");t._local().manifestEtag=e,t._setDirty(!0)}},compositeState:{get:function(){return this._data.state||"unmodified"},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new s(s.INVALID_PARAMS,"Expecting a string.");if("unmodified"!==e&&"modified"!==e&&"pendingDelete"!==e&&"committedDelete"!==e&&"pendingDiscard"!==e)throw new s(s.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDiscard", "pendingDelete", or "committedDelete".');this._data.state=e,t._setDirty(!0)}},isBound:{get:function(){return this.manifestEtag&&this.compositeHref},set:function(){throw new s(s.READ_ONLY,"Cannot set the property isBound. Use resetIdentity instead.")}},_localStorage:{get:function(){return this._core._localStorage},set:function(e){this._core._localStorage=e}},hasLocalStorage:{get:function(){return this._core.hasLocalStorage},set:function(e){this._core.hasLocalStorage=e}},_isDirty:{get:function(){return this._core._isDirty},set:function(e){this._core._isDirty=e}},isDirty:{get:function(){return this._core.isDirty},set:function(e){this._core.isDirty=e}},localData:{get:function(){return this._core._stringify(!1)},set:function(){throw new s(s.READ_ONLY,"Cannot set the property localData.")}},prettifiedLocalData:{get:function(){return this._core._stringify(!1,!0)},set:function(){throw new s(s.READ_ONLY,"Cannot set the property localData.")}},remoteData:{get:function(){return this._core._stringify(!0)},set:function(){throw new s(s.READ_ONLY,"Cannot set the property remoteData.")}},pendingElements:{get:function(){return this._pendingElements},set:function(){throw new s(s.READ_ONLY,"Cannot set the property pendingElements.")}},changeCount:{get:function(){return this._core.changeCount},set:function(e){this._core.changeCount=e}},readOnly:{get:function(){return this._core._readOnly},set:function(e){this._core._readOnly=e}}}),l.prototype.parse=function(e){if("string"!=typeof e)throw new s(s.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new s(s.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message)}return this._setData(t,this._core._readOnly)},l.prototype.getElementWithId=function(e){return this._createElement(this._core.getChildWithId(e))},l.prototype.getElementWithAbsolutePath=function(e){return this._createElement(this._core.getChildWithAbsolutePath(e))},l.prototype.addElement=function(e,t,n,i,o,r){if("string"!=typeof e)throw new s(s.INVALID_PARAMS,"Element must have a name of type string");if("string"!=typeof t)throw new s(s.INVALID_PARAMS,"Element must have a type of type string");if("string"!=typeof n)throw new s(s.INVALID_PARAMS,"Element must have a path of type string");var a=this._core.addChild(e,i,o,r);try{a.path=n}catch(e){throw this._core.removeChild(a),e}return a._data.type=t,this._createElement(a)},l.prototype.updateElement=function(e){var t=this.getChildWithId(e.rootNode.id);if(!t)throw new s(s.INVALID_PARAMS,"Element does not exist in branch.");var n=this._core.replaceChild(e.rootNode,t.path);return this._deleteElement(e),n},l.prototype.abandonElement=function(e){this._deleteElement(e)},l.prototype.getChildWithId=function(e){return this._core.getChildWithId(e)},l.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e)},l.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e)},l.prototype.addChild=function(e,t,n,i){return this._core.addChild(e,t,n,i)},l.prototype.removeChild=function(e){return this._core.removeChild(e)},l.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n)},l.prototype.copyChild=function(e,t,n,i,o,r){return this._core.copyChild(e,t,n,i,o,r)},l.prototype.replaceChild=function(e,t,n,i){return this._core.replaceChild(e,t,n,i)},l.prototype.allComponents=function(){return this._core.allComponents()},l.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e)},l.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e)},l.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e)},l.prototype.addComponent=function(e,t,n,i,o,r,a,s,c,l){return this._core.addComponent(e,t,n,i,o,r,a,s,c,l)},l.prototype.addComponentWithUploadResults=function(e,t,n,i,o){return this._core.addComponentWithUploadResults(e,t,n,i,o)},l.prototype.updateComponent=function(e,t,n,i){return this._core.updateComponent(e,t,n,i)},l.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t)},l.prototype.removeComponent=function(e){return this._core.removeComponent(e)},l.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t)},l.prototype.copyComponent=function(e,t,n,i,o){return this._core.copyComponent(e,t,n,i,o)},l.prototype.replaceComponent=function(e,t,n,i){return this._core.replaceComponent(e,t,n,i)},l.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},l.prototype.copy=function(){var e=new l(JSON.parse(JSON.stringify(this._data)));return e._localStorage=this._localStorage,e},l.prototype.setLocalData=function(e,t){if("string"!=typeof e)throw new s(s.INVALID_DATA,"Local data key must be a string.");if(this._local().customData=this._local().customData||{},Object(t)===t)try{JSON.stringify(t)}catch(e){throw new s(s.INVALID_DATA,"Local data value must be serializable.",e)}this._local().customData[e]=t,this._setDirty(!0)},l.prototype.getLocalData=function(e){if("string"!=typeof e)throw new s(s.INVALID_DATA,"Local data key must be a string.");return this._local().customData&&this._local().customData[e]},l.prototype._createElement=function(e){var t;if(e){var n=JSON.parse(JSON.stringify(e._data));n["manifest-format-version"]=this._data["manifest-format-version"],delete n.path,(t=new a(n,this,this._core._readOnly))&&this._localStorage&&(t._localStorage=this._localStorage,t._updateLocalDataFromBranch(this),this._localStorage.registerInMemoryBranchOrElement(t))}return t&&this._pendingElements.push(t),t},l.prototype._deleteElement=function(e){var t=this._pendingElements.indexOf(e);if(t<0)throw new s(s.INVALID_PARAMS,"Unknown element.");this._pendingElements.splice(t,1),this._localStorage&&this._localStorage.unregisterInMemoryBranchOrElement(e)},l.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new s(s.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new s(s.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new s(s.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core)},l.prototype._verify=function(e){return"string"!=typeof e.id?new s(s.INVALID_DATA,"Manifest is missing an id of type string"):"string"!=typeof e.name?new s(s.INVALID_DATA,"Manifest is missing a name of type string"):"string"!=typeof e.type?new s(s.INVALID_DATA,"Manifest is missing a type of type string"):"number"!=typeof e["manifest-format-version"]?new s(s.INVALID_DATA,"Manifest is missing a manifest-format-version of type number"):null},l.prototype._setData=function(e,t){this.originalManifestFormatVersion=e["manifest-format-version"],function(e){var t=e["manifest-format-version"];if(t<6){if(t<4)throw new s(s.INVALID_DATA,"Encountered manifest format version "+e["manifest-format-version"]+". Format version conversion not yet implemented for that version.");t<5&&function e(t){var n,i,o=t.components;if(o)for(i=o.length,n=0;n<i;n++)delete o[n].localStorageAssetId;var r=t.children;if(r)for(i=r.length,n=0;n<i;n++)e(r[n])}(e),t<6&&function e(t,n){n&&t.path&&delete t.path;var o,r=t.components;if("object"===i(r))for(o=0;o<r.length;o++){var a=r[o];"number"==typeof a.version&&(a.version=a.version.toString())}var s=t.children;if("object"===i(s))for(o=0;o<s.length;o++)e(s[o])}(e,!0)}}(e),e.local&&(e.local.version=2);var n=this._verify(e);if(null===n)return e["manifest-format-version"]=6,this._core=new r(e,this,t),this._data=e,this;throw n},l.prototype._reset=function(e,t){if(this._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");this._data.local&&(delete this._data.local.manifestEtag,delete this._data.local.compositeHref,delete this._data.local.links,delete this._data.local.assetId,delete this._data.local.repoMetadata,delete this._data.local.isWritable,delete this._data.local.parentAssetId,delete this._data.local.isParentWritable,delete this._data.local.isRenamePending,delete this._data.local.storageAssignee,delete this._data.local.customData),e||(this._data.id=c.generateUuid()),this._data.state="modified",this._core._recursiveReset(this._data,t),this._core._setDirty()},l.prototype._resetBinding=function(e){this._reset(!0,e)},l.prototype._resetIdentity=function(e){this._reset(!1,e)},l.prototype._local=function(){return this._core._local()},l.prototype._setDirty=function(e){this._core._setDirty(e)},l.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t)},l.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n)},e.exports=l},function(e,t){e.exports=function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.filename=t,this.size=n,this.range=i}},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var o=n(0),r=n(2);function a(e,t){e?this._setData(e):this._data={},this._readOnly=t}var s={unmodified:"unmodified",modified:"modified",pendingDiscard:"pendingDiscard",pendingDelete:"pendingDelete",committedDelete:"committedDelete"};a.STATES=s,a._UploadResults=function(e){this.compositeId=e,this.records={}},a._UploadRecord=function(e,t,n,i,o,r){this.id=e,this.etag=t,this.version=n,this.md5=i,this.length=o,this.type=r},Object.defineProperties(a.prototype,{id:{get:function(){return this._data.id},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._owner)throw new o(o.READ_ONLY,"Cannot change the id of a component that is part of a branch or element.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.id=e,this._setDirty()}},name:{get:function(){return this._data.name},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.name=e,this._setDirty()}},type:{get:function(){return this._data.type},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.type=e,this._setDirty()}},path:{get:function(){return this._data.path},set:function(e){if(this._data.path!==e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!r.isValidPath(e))throw new o(o.INVALID_PARAMS,"Expecting a valid path.");this._owner?this._owner._core._setPathOfComponent(this,e):(this._data.path=e,this._parentPath=""),this._setDirty()}}},parentPath:{get:function(){return this._parentPath},set:function(){throw new o(o.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get:function(){return this._data.path&&this._owner?r.appendPathElements(this._parentPath,this._data.path):void 0},set:function(){throw new o(o.READ_ONLY,"absolutePath is read-only.")}},relationship:{get:function(){return this._data.rel},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.rel=e,this._setDirty()}},state:{get:function(){return this._data.state},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");if(!s.hasOwnProperty(e))throw new o(o.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDiscard", "pendingDelete", or "committedDelete".');this._data.state=e,this._setDirty()}},etag:{get:function(){return this._data.etag},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.etag=e,this._setDirty()}},md5:{get:function(){return this._data.md5},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.md5=e,this._setDirty()}},version:{get:function(){return this._data.version},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(void 0!==e&&"string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.version=e,this._setDirty()}},length:{get:function(){return this._data.length},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.length=e,this._setDirty()}},width:{get:function(){return this._data.width},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.width=e,this._setDirty()}},height:{get:function(){return this._data.height},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.height=e,this._setDirty()}}});var c={name:!0,id:!0,state:!0,path:!0,rel:!0,type:!0,etag:!0,length:!0,version:!0,md5:!0,width:!0,height:!0};a.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),i=n.length;for(e=0;e<i;e++){var o=n[e];c[o]||t.push(o)}return t},a.prototype.getValue=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');return this._data[e]},a.prototype.setValue=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');this._data[e]=t,this._setDirty()},a.prototype.removeValue=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');delete this._data[e],this._setDirty()},a.prototype.getLink=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');return this._data._links?this._data._links[e]:void 0},a.prototype.setLink=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("object"!==i(e))throw new o(o.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var n=this._data._links;n||(n=this._data._links={}),n[t]=e,this._setDirty()},a.prototype.removeLink=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var t=this._data._links;t&&(delete t[e],Object.keys(t).length<1&&delete this._data._links,this._setDirty())},a.prototype.isEqualTo=function(e,t){return r.objectsEqual(this._data,e._data,t)},a.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t},a.prototype._setDirty=function(){this._owner&&this._owner._setDirty()},a.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Component is missing an id of type string"):null},e.exports=a},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(1),r=n(2),a=n(7),s=["ROOT_DIR","POLL_INTERVAL","RENDITION_SIZES","FULL_RENDITION_CONFIG","EXTERNAL_LINK_PREFETCH","LOCALE","STORAGE_API_KEY","USER_AGENT_HEADER","SYNC_POLICY","ELEMENT_TYPE_FILTERS","AUTO_START_POLLING","SHARED_LOCAL_STORAGE","ALLOWED_DOMAINS","CLIENT_DESCRIPTION","DEVICE_ID","DEVICE_DESCRIPTION","APP_DESCRIPTION","DEFAULT_RENDITION_404_BACKOFF","LOCAL_SETTINGS","PLATFORM_FOLDER_REFRESH_INTERVAL"],c="bookmarks.json",l={VERSION:1,DL_NAMESPACE:"library",DL_PREFIX:"library#",VERSION_KEY:"library#version",RELATIONSHIP_KEY:"library#rel",WIDTH_KEY:"library#width",HEIGHT_KEY:"library#height",LENGTH_KEY:"library#length",IS_FULL_SIZE_KEY:"library#isFullSize",IS_PREFERRED_THUMBNAIL_KEY:"library#isPreferredThumbnail",MODIFIED_KEY:"library#modified",CREATED_KEY:"library#created",REMOVED_KEY:"library#removed",MODIFIED_DATA_KEY:"library#modifiedData",CREATED_DATA_KEY:"library#createdData",REMOVED_DATA_KEY:"library#removedData",DESCRIPTION_KEY:"library#description",DESCRIPTION_DATA_KEY:"library#descriptionData",GROUPS_KEY:"library#groups",ORDER_KEY:"library#order",PARENT_KEY:"library#parentId",CLASSIFIER_KEY:"library#classifier",SOURCE_REF_KEY:"library#sourceRef",SOURCE_MODIFIED_KEY:"library#sourceModified",LINK_TYPE_KEY:"library#linktype",LINK_URL_KEY:"library#linkurl",LINK_LOCAL_PATH_KEY:"library#linklocalpath",REPRESENTATION_ORDER_KEY:"library#representationOrder",RENDITION_TYPE_KEY:"library#renditiontype",SHA_KEY:"library#sha256",DOCUMENT_ID_KEY:"library#documentId",DOCUMENT_TYPE_KEY:"library#documentType",DEPENDENCIES_KEY:"library#dependencies",LOCALIZED_NAME_KEY:"library#localizedName",AUTO_NAMED_KEY:"library#autoName",ANIMATION_ELEMENT_TYPE:"application/vnd.adobe.element.animation+dcx",BRUSH_ELEMENT_TYPE:"application/vnd.adobe.element.brush+dcx",COLOR_ELEMENT_TYPE:"application/vnd.adobe.element.color+dcx",IMAGE_ELEMENT_TYPE:"application/vnd.adobe.element.image+dcx",LAYER_STYLE_ELEMENT_TYPE:"application/vnd.adobe.element.layerstyle+dcx",COLOR_THEME_ELEMENT_TYPE:"application/vnd.adobe.element.colortheme+dcx",CHARACTER_STYLE_ELEMENT_TYPE:"application/vnd.adobe.element.characterstyle+dcx",PARAGRAPH_STYLE_ELEMENT_TYPE:"application/vnd.adobe.element.paragraphstyle+dcx",TEXT_ELEMENT_TYPE:"application/vnd.adobe.element.text+dcx",REPRESENTATION_CONTENT_VALUES:{"application/vnd.adobe.color+json":{namespace:"color",key:"data"},"application/vnd.adobe.text+json":{namespace:"text",key:"data",contentFromData:!0}},DEFAULT_GROUP_CLASSIFIER:"$default",COMPOSITE_TYPE:"application/vnd.adobe.library+dcx",LINK_REPRESENTATION_TYPE:"application/vnd.adobe.library.link+dcx",GROUP_TYPE:"application/vnd.adobe.library.group+dcx",ELEMENTS_NAME:"elements",REMOVED_ELEMENTS_NAME:"removed_elements",GROUPS_NAME:"groups",DATA_COLLABORATION_ROLE:"collaborationRole",BOOKMARKS_FILENAME:c,BOOKMARKS_FILE_VERSION:2,BOOKMARKS_PATH:"/bookmarks",BOOKMARKS_MONITOR_PATHS:[c,"collab-bookmarks.json"].map((function(e){return"/sync/adobe-libraries/".concat(e)})),BOOKMARKS_TYPES:{public:{allowed:["url"],required:["url"]},collab:{allowed:["urn","role"],required:{on_pushed_new:[],default:["urn"]}}},PLATFORM_DATA_FILENAME:"platform-data.json",PLATFORM_DATA_VERSION:1,PLATFORM_DATA_TTL:2592e6,PLATFORM_FOLDER_REFRESH_INTERVAL:6e4,PLATFORM_HIDDEN_FOLDERS:["appdata"],STOCK_NAMESPACE:"adobestock",STOCK_DATA_KEY:"trackingdata",STOCK_STATE_PURCHASED:"purchased",TOOLKIT_NAMESPACE:"toolkit",TOOLKIT_ID_KEY:"id",RELATIONSHIP_CHILD:"child",PUBLIC_USER_ID:"public",COLLABORATED_CLOUD_ID:"collaborated",DEFAULT_CLOUD_ID:"creative_cloud",DEFAULT_CORESYNC_CLOUD_ID:"00000000-0000-0000-0000-000000000000",STORAGE_ASSETS_PATH:"/assets/",LIBRARY_SYNC_GROUP:"adobe-libraries",CP_CLOUD_ID:"community-platform",CP_STORAGE_ASSETS_PATH:"/content/2/",VULCAN_PREFIX:"vulcan.SuiteMessage.",VULCAN_STARTUP_MESSAGE:"cclibraries.service.Initialized",VULCAN_SHUTDOWN_REQUEST:"cclibraries.service.TerminateServiceRequest",VULCAN_QUERY_REQUEST:"cclibraries.service.QueryRequest",VULCAN_QUERY_RESPONSE:"cclibraries.service.QueryResponse",VULCAN_LIBRARY_CHANGED_LOCAL_TYPE:"cclibraries.service.LibraryChangedLocal",VULCAN_LIBRARY_CHANGED_REMOTE_TYPE:"cclibraries.service.LibraryChangedRemote",VULCAN_LIBRARY_DELETED_TYPE:"cclibraries.service.LibraryDeleted",VULCAN_COLLECTIONS_LOADED_TYPE:"cclibraries.service.LibrariesLoaded",VULCAN_COLLECTIONS_UNLOADED_TYPE:"cclibraries.service.LibrariesUnloaded",VULCAN_PROXY_QUERY_REQUEST:"cclibraries.service.QueryProxySettingsRequest",VULCAN_PROXY_QUERY_RESPONSE:"cclibraries.service.QueryProxySettingsResponse",VULCAN_PROXY_CHANGE_MESSAGE:"cclibraries.service.ProxySettingsChanged",VULCAN_APP_READY_MESSAGE:"cclibraries.accessor.AppReady",VULCAN_APP_SEND_ACTION_MESSAGE:"cclibraries.accessor.EditElementRequest",VULCAN_APP_ACTION_ACCEPTED_MESSAGE:"cclibraries.accessor.EditAcceptedMessage"},u=function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._listenerManager=new a(["change"]),this.MAX_ELEMENTS=1e4,this.MAX_REMOVED_ELEMENTS=2e3,this.MAX_COMPONENT_SIZE=1073741824,this.VALID_RELATIONS=["rendition","primary","alternate"],this.VALID_LIBRARY_RENDITION_TYPES=["banner","cover"],this.VALID_SYNC_POLICIES=["manifestAndAssets","manifestOnly"],this.ELEMENT_TYPE_FILTERS=[],this.VECTOR_RENDITION_ELEMENT_TYPES=["application/illustrator"],Object.keys(l).forEach((function(e){return t[e]=l[e]})),this.FS_RETRY_INTERVAL=100,this.FS_MAX_RETRIES=10,this.MAX_DCX_CONCURRENT_COPIES=10,this.REMOVE_OPERATION_TIMEOUT=100,this.EXPORT_VERSION=1,this.EXPORT_EXTENSION=".cclibs",this.ANALYTICS_ENABLED=!1,this.ANALYTICS_ELEMENT_UPDATE_THRESHOLD=500,this.STORAGE_API_KEY="",this.USER_AGENT_HEADER=void 0,this.SYNCING_ENABLED=!0,this.VULCAN_QUERY_TIMEOUT=8e3,this.DEFAULT_MAX_SYNC_INTERVAL=1e4,this.RETRY_FAIL_MAX_SYNC_INTERVAL=6e4,this.MAX_SYNC_INTERVAL=this.DEFAULT_MAX_SYNC_INTERVAL,this.POLL_INTERVAL=1,this.AUTO_START_POLLING=!1,this.RENDITION_SIZES={},this.FULL_RENDITION_CONFIG={},this.BACKOFF_INTERVALS=[1,1,2,3,5,8,13,21,34,55],this.ERROR_RETRY_INTERVALS=[30,60,120],this.NETWORK_TIMEOUT=6e5,this.IMAGE_SERVICE_NETWORK_TIMEOUT=18e4,this.RETRY_RANDOM_SECONDS=30,this.RENDITION_MAX_RETRIES=2,this.DEFAULT_RENDITION_RETRY_INTERVAL=1e3,this.RENDITION_RETRY_INTERVAL=this.DEFAULT_RENDITION_RETRY_INTERVAL,this.DEFAULT_RENDITION_404_BACKOFF=3e5,this.RENDITION_404_BACKOFF=this.DEFAULT_RENDITION_404_BACKOFF,this.LOCAL_RENDITION_MAX_RETRIES=5,this.LOCAL_RENDITION_RETRY_INTERVAL=200,this.MAX_UPDATE_CONFLICTS=5,this.MAX_REDIRECT_FOLLOW=5,this.MAX_HEAD_REDIRECT_FOLLOW=0,this.MAX_RECOVERED_LIBRARIES=10,this.ELMO_LOCAL_LIBRARY_LIMIT=2e4,this.ELMO_SERVER_RECOVERED_LIMIT=100,this.ADOBE_AUTHENTICATED_DOMAINS=["stock.adobe.com","stock.stage.adobe.com","adobe.io","adobestock.com","fotolia.net"],this.ALLOWED_DOMAINS=["cclibraries-defaults-cdn.adobe.com","cclibraries-defaults-cdn.stage.adobe.com","stageastockcdn.net","ftcdn.net"],this.DISALLOWED_DOMAINS={"cc-api-storage-stage.adobe.io":["stock.adobe.com"],"platform-cs-stage.adobe.io":["stock.adobe.com"],"cc-api-storage.adobe.io":["stock.stage.adobe.com"],"platform-cs.adobe.io":["stock.stage.adobe.com"]},this.SHA_CACHE={},this.DEFAULT_CONTENT_LOCATIONS=[],this.SYNC_POLICY="manifestAndAssets",this.REMOVED_ELEMENTS_CACHE_TIMEOUT=6e5,this.RENDITION_CACHE_FILE="cache.json",this.RENDITION_CACHE_PLACEHOLDER="<placeholder>",this.SHARED_LOCAL_STORAGE_TEAM_LIBRARIES_BETA_VERSION=21,this.SHARED_LOCAL_STORAGE=!0,this.SHARED_LOCAL_STORAGE_VERSION=23,this.SHARED_LOCAL_STORAGE_MIN_CLIENT_VERSION=6,this.SHARED_LOCAL_STORAGE_MAX_CLIENT_VERSION=23,this.LOCAL_SETTINGS={},this.ELEMENT_ACTIONS=["edit","openStock","editInSource"],this.LIBRARY_ACTIONS=["editInSource"],this.DOCUMENT_LIBRARY_ACTION_PRODUCT_MAP={types:{"application/vnd.adobe.xd.cloudproject+dcx":["SPKR"]},products:{SPKR:{minVersion:"34",appCode:"SPKR",appName:"XD",action:"editInSource"}}},this.ELEMENT_ACTION_PRODUCT_MAP={types:{"application/vnd.adobe.element.image+dcx":{"application/illustrator":["ILST_EDIT","ILST_PLACE","IDSN_PLACE"],"image/svg+xml":["ILST_EDIT","ILST_PLACE"],"application/vnd.adobe.indesign-idms":["IDSN_EDIT","IDSN_PLACE"],"image/vnd.adobe.photoshop":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"application/photoshop":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"application/photoshop.large":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"image/png":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/jpeg":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/jpg":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE","ILST_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/gif":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/bmp":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/x-portable-bitmap":["PHXS_EDIT","PHXS_PLACE"],"image/x-pict":["PHXS_EDIT","PHXS_PLACE"],"image/x-pcx":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-graymap":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-anymap":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-pixmap":["PHXS_EDIT","PHXS_PLACE"],"image/x-tga":["PHXS_EDIT","PHXS_PLACE"],"image/tiff":["PHXS_EDIT","PHXS_PLACE"],"image/vnd.wap.wbmp":["PHXS_EDIT","PHXS_PLACE"]},"application/vnd.adobe.element.text+dcx":{"application/illustrator-text":["ILST_EDIT_TEXT"],"application/vnd.adobe.indesign-idms-text":["IDSN_EDIT_TEXT"]},"application/vnd.adobe.element.template+dcx":{"image/vnd.adobe.photoshop.template":["PHXS_PLACE"],"application/illustrator.template":["ILST_PLACE"],"application/vnd.adobe.indesign.template":["IDSN_PLACE"]},"application/vnd.adobe.element.3d+dcx":{"application/vnd.adobe.obj.3d+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.material+dcx":{"application/vnd.adobe.mdl.material+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.light+dcx":{"application/vnd.adobe.ibl.light+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.animation+dcx":{"application/vnd.adobe.animate-xfl+zip":["FLPR_EDIT"],"application/vnd.adobe.animate-sym+zip":["FLPR_EDIT"]}},products:{ILST_EDIT:{minVersion:"19.2",appCode:"ILST",appName:"Illustrator",action:"edit"},ILST_EDIT_TEXT:{minVersion:"22",appCode:"ILST",appName:"Illustrator",action:"edit"},IDSN_EDIT:{minVersion:"11.2",appCode:"IDSN",appName:"InDesign",action:"edit"},IDSN_EDIT_TEXT:{minVersion:"13",appCode:"IDSN",appName:"InDesign",action:"edit"},PHXS_EDIT:{minVersion:"16.1.2",appCode:"PHXS",appName:"Photoshop",action:"edit"},FLPR_EDIT:{minVersion:"16.1",appCode:"FLPR",appName:"Flash",action:"edit"},PHXS_PLACE:{minVersion:"17.0.0",appCode:"PHXS",appName:"Photoshop",action:"openStock"},ILST_PLACE:{minVersion:"20.0.0",appCode:"ILST",appName:"Illustrator",action:"openStock"},IDSN_PLACE:{minVersion:"11.4.0",appCode:"IDSN",appName:"InDesign",action:"openStock"},PPRO_PLACE:{minVersion:"10.3.0",appCode:"PPRO",appName:"Premiere Pro",action:"openStock"},AEFT_PLACE:{minVersion:"13.8.0",appCode:"AEFT",appName:"After Effects",action:"openStock"},ESHR_PLACE:{minVersion:"0.1",appCode:"ESHR",appName:"Project Felix",action:"openStock"}},installedApps:[]},this.TLS_DISCOVERY_PORT_RANGE=[45623,45625],this.TLS_DELAY_ON_DECLINE=500,this.TLS_DELAY_ON_READY=250}var t,n;return t=e,(n=[{key:"addChangeListener",value:function(e){this._listenerManager.add("change",e)}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e)}},{key:"setLocalSetting",value:function(e,t){this.LOCAL_SETTINGS[e]=t,this._listenerManager.notify("change")}},{key:"setParameter",value:function(e,t){if(-1===s.indexOf(e))throw new o(o.INVALID_PARAMETER,"Parameter not configurable");if("SYNC_POLICY"===e&&-1===this.VALID_SYNC_POLICIES.indexOf(t))throw new o(o.INVALID_PARAMETER,"Invalid value for SYNC_POLICY");"POLL_INTERVAL"===e&&(t=Math.max(1,t)),this[e]=t}},{key:"getBackoffTicks",value:function(e){var t=this.BACKOFF_INTERVALS;return t[Math.max(0,Math.min(e,t.length-1))]-1}},{key:"getRetryAfterHeader",value:function(e){if(e){var t=e["retry-after"]||e["Retry-After"];if(t)try{var n=parseInt(t,10);if(n)return Math.max(0,n);var i=Date.parse(t);if(i){var o=Date.now();return Math.max(0,i-o)/1e3+Math.floor(Math.random()*this.RETRY_RANDOM_SECONDS)}}catch(e){}}return 0}},{key:"getLocationHeader",value:function(e){if(e){var t=e.location||e.Location;if(t)return t}}},{key:"getContentTypeHeader",value:function(e){if(e){var t=e["content-type"]||e["Content-Type"];if(t){var n=t.indexOf(";");return n>0&&(t=t.substring(0,n)),t}}}},{key:"getContentLengthHeader",value:function(e){if(e){var t=e["content-length"]||e["Content-Length"];return Number(t)||void 0}}},{key:"isUnrecoverableClientError",value:function(e,t){return!!e&&e>=400&&e<500&&(401!==e||!!t)&&407!==e&&408!==e}},{key:"isRedirect",value:function(e){return 301===e||302===e||303===e||307===e}},{key:"_checkDomain",value:function(e,t){return t.some((function(t){if(e===t)return!0;var n=e.indexOf("."+t);return-1!==n&&n===e.length-t.length-1}))}},{key:"isAdobeDomain",value:function(e){return"string"==typeof e&&this._checkDomain(e,this.ADOBE_AUTHENTICATED_DOMAINS)}},{key:"validateURL",value:function(e,t){if(!e)return new o(o.URL_VALIDATION_FAILED,"URL not specified");var n=r.parseURI(e);if("https"!==n.scheme)return new o(o.URL_VALIDATION_FAILED,"URL must be https://");if(!this.isAdobeDomain(n.authority)&&!this._checkDomain(n.authority,this.ALLOWED_DOMAINS))return new o(o.URL_VALIDATION_FAILED,"URL domain not in allowedlist");var i=t&&t._syncManager._storageHost,a=i&&this.DISALLOWED_DOMAINS[i];return this._checkDomain(n.authority,a||[])?new o(o.URL_VALIDATION_FAILED,"URL domain does not match IMS environment (stage-production mismatch)"):null}},{key:"formatElementActionMapForClient",value:function(e){return e<9?{types:this.ELEMENT_ACTION_PRODUCT_MAP.types["application/vnd.adobe.element.image+dcx"],products:this.ELEMENT_ACTION_PRODUCT_MAP.products,installedApps:this.ELEMENT_ACTION_PRODUCT_MAP.installedApps}:this.ELEMENT_ACTION_PRODUCT_MAP}},{key:"updateElementActionMap",value:function(e,t){if(e<9){var n=t.types;t.types=this.ELEMENT_ACTION_PRODUCT_MAP.types,t.types["application/vnd.adobe.element.image+dcx"]=n}this.ELEMENT_ACTION_PRODUCT_MAP=t}},{key:"isNewBookmarkFormatSupported",value:function(e){return e>=18}},{key:"shouldPrefetchFullRendition",value:function(e){var t=(this.FULL_RENDITION_CONFIG||{})[e.type];if(!t)return!1;var n=!1;return Object.keys(t).forEach((function(i){var o=t[i];if("IF_NO_MATCHING_REPRESENTATION"===o.condition&&o.types){var r=e.representations.every((function(e){return!o.types.includes(e.type)}));n=n||r}})),n}},{key:"shouldPrefetchExternalLink",value:function(e){if(!e.isExternalLink)return!1;var t=(this.EXTERNAL_LINK_PREFETCH||{})[e.element.type];return void 0===t||t}},{key:"addToRenditionSizeConfig",value:function(e){var t=this.RENDITION_SIZES,n=JSON.parse(JSON.stringify(t["*"]||[])),i=e["*"]||[];Object.keys(t).forEach((function(n){if(!e[n]){var o=t[n];i.forEach((function(e){-1===o.indexOf(e)&&o.push(e)})),t[n]=o}})),Object.keys(e).forEach((function(i){var o=t[i]||JSON.parse(JSON.stringify(n));e[i].forEach((function(e){-1===o.indexOf(e)&&o.push(e)})),t[i]=o})),this.setParameter("RENDITION_SIZES",t)}},{key:"addToFullRenditionConfig",value:function(e){var t=this.FULL_RENDITION_CONFIG;Object.keys(e).forEach((function(n){var i=t[n]||{};e[n].forEach((function(e){e.id&&(i[e.id]=e)})),t[n]=i})),this.setParameter("FULL_RENDITION_CONFIG",t)}}])&&i(t.prototype,n),e}();Object.keys(l).forEach((function(e){return u[e]=l[e]})),e.exports=u},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(0),u=n(32),h=n(63),p=n(64),d=n(1),_=n(68),f=n(9),m=n(6),v=n(3),y=n(10),g=n(69),E=n(4).promisify,O=function(e){function t(e,n,o){var a,c;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),c=s(t).call(this),(a=!c||"object"!==i(c)&&"function"!=typeof c?r(this):c)._collection=e,a._dcxComposite=n,a._dcxBranch=n.current,a._publicId=o,a._filterCache={},a._renditionCache=new g(r(a)),a._autoGCMode={},a._transactionCount=0,a._commitInProgress=!1,a._pendingCommit=!1,a._onCommitCallbacks=[],a._dcxLock=new f,a._networkLock=new f,a._syncState=void 0,a._deletedLocally=!1,a._deletedFromServer=!1,a._waitForSyncToFinishCallbacks=[],a._errors=[],a._pushFailedDueToQuota=!1,a._numUpdateConflicts=0,a._numActiveCopyNodeOperations=0,a._pendingCopyNodeOperations=[],a._dcxBranch.getChildrenOf().forEach((function(e){e.name===a._config.ELEMENTS_NAME&&(a._dcxElementsNode=e),e.name===a._config.REMOVED_ELEMENTS_NAME&&(a._dcxRemovedElementsNode=e),e.name===a._config.GROUPS_NAME&&(a._dcxGroupsNode=e)})),a._dcxElementsNode||(a._dcxElementsNode=a._dcxBranch.addChild(a._config.ELEMENTS_NAME)),a._dcxCompositeRenditionMap=m.getCompositeRenditionMap(a._dcxBranch),a._elements=[],a._removedElements=[],a._groups=[],a._dcxBranch.getChildrenOf(a._dcxElementsNode).forEach((function(e){var t=new p(r(a),e);a._addElementToFilter(t),a._elements.push(t)})),a._dcxRemovedElementsNode&&(a._dcxBranch.getChildrenOf(a._dcxRemovedElementsNode).forEach((function(e){var t=new p(r(a),e);a._removedElements.push(t)})),a._sortRemovedElements()),a._dcxGroupsNode&&a._dcxBranch.getChildrenOf(a._dcxGroupsNode).forEach((function(e){var t=new h(r(a),e);a._groups.push(t)})),a._services.hasFileSystem()||(a._dcxBaseBranch=a._dcxBranch.copy()),a.addChangeListener(a._updateStorageUsed.bind(r(a))),a._updateStorageUsed(),a}var n,u;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(u=[{key:"_setName",value:function(e){a(s(t.prototype),"_setName",this).call(this,e),this._dcxComposite.isRenamePending=!0}},{key:"_getRemovedElementsNode",value:function(){return this._dcxRemovedElementsNode||(this._dcxRemovedElementsNode=this._dcxBranch.addChild(this._config.REMOVED_ELEMENTS_NAME)),this._dcxRemovedElementsNode}},{key:"_getGroupsNode",value:function(){return this._dcxGroupsNode||(this._dcxGroupsNode=this._dcxBranch.addChild(this._config.GROUPS_NAME)),this._dcxGroupsNode}},{key:"_markDeletedLocally",value:function(e){this._elements.forEach((function(t){return t._markDeletedLocally(e)})),this._groups.forEach((function(t){return t._markDeletedLocally(e)})),a(s(t.prototype),"_markDeletedLocally",this).call(this,e)}},{key:"_removeAllListeners",value:function(){this._elements.forEach((function(e){return e._removeAllListeners()})),this._groups.forEach((function(e){return e._removeAllListeners()})),a(s(t.prototype),"_removeAllListeners",this).call(this)}},{key:"_toJSON",value:function(){return{id:this.id,name:this.name,elements:this._elements.map((function(e){return e._toJSON()})),renditionCache:this._renditionCache.serializeCache(),groups:this._groups.map((function(e){return e._toJSON()}))}}},{key:"_getRenditionCache",value:function(){var e={},t=function(t){e[t.id]=JSON.parse(JSON.stringify(t._renditionCache))};return this._elements.forEach(t),this._removedElements.forEach(t),e}},{key:"_doCommitCallbacks",value:function(e){var t=this,n=this._onCommitCallbacks;this._onCommitCallbacks=[],n.forEach((function(n){n.waitForSuccess&&!e?t._onCommitCallbacks.push(n):t._waitForCommit(n.callback)}))}},{key:"_doCommit",value:function(e){var t=this,n=function(n){t._doCommitCallbacks(n),function(){if(e&&!t._config.SHARED_LOCAL_STORAGE){if(t._deletedLocally)return;t._collection._clearSyncErrors(),t._push(),t._collection._resetPollBackoff()}}()};this._services.hasFileSystem()?this._commitInProgress?this._pendingCommit=!0:(this._commitInProgress=!0,this._storageInterface.commitManifest(this,(function(i,o){!function(e,n){e&&(e=v.getCommitError(e,t.id,"Failed to write composite to disk")),t._collection._reportCommitError(e)}(i),t._commitInProgress=!1,t._pendingCommit?(t._pendingCommit=!1,0===t._transactionCount&&t._doCommit(e)):n(o)}))):n()}},{key:"_waitForCommit",value:function(e,t){this._commitInProgress||this._transactionCount>0?this._onCommitCallbacks.push({callback:e,waitForSuccess:t}):this._renditionCache._waitForCommit(e)}},{key:"_notifyChange",value:function(){this._listenerManager.notify("change"),this._collection._notifyChange()}},{key:"_commit",value:function(e,t){0===this._transactionCount&&(t||(this._updateModifiedTime(),this._notifyChange()),this._doCommit(!e))}},{key:"_commitMetadata",value:function(){this._commit()}},{key:"_unblockCommits",value:function(){this._commitInProgress||0!==this._transactionCount||(this._services.log("Unblocking queued commits"),this._doCommitCallbacks(!0))}},{key:"_wrapOperation",value:function(e,t){var n;this._beginOperation();try{n=e.call(t)}catch(e){throw this._transactionCount--,e}return this._endOperation(),n}},{key:"_beginOperation",value:function(){this._transactionCount++}},{key:"_endOperation",value:function(){this._transactionCount--,this._commit()}},{key:"_updateModifiedTime",value:function(){var e=Date.now();this._dcxNode.setValue(this._config.MODIFIED_KEY,e)}},{key:"_updateCreatedTime",value:function(){var e=Date.now();this._dcxNode.setValue(this._config.CREATED_KEY,e),this._dcxNode.setValue(this._config.MODIFIED_KEY,e)}},{key:"_getMissingLocalComponents",value:function(){return this._elements.reduce((function(e,t){return e.concat(t._getMissingLocalComponents())}),[])}},{key:"_gcLocalData",value:function(e){var t=this,n=[],i={},o=[];if(this._removedElements.forEach((function(e){e._shouldGCLocalData()&&(n.push(e),e._forEachRepresentation((function(e){var t=e._dcxComponent,n=e._getCurrentComponentPath();t&&n&&t.etag&&"modified"!==t.state?(i[n]=i[n]||[],i[n].push(t.id)):n&&o.push(n)})))})),0!==n.length){o.forEach((function(e){delete i[e]})),this._elements.forEach((function(e){e._forEachRepresentation((function(e){var t=e._getCurrentComponentPath();t&&delete i[t]}))}));var r=[];Object.keys(i).forEach((function(e){r.push.apply(r,i[e])})),n.forEach((function(e){return t._renditionCache.clearCache(e)})),this._services.log("Removing local files for components: [ "+r.join(", ")+" ]"),this._dcxComposite.removeLocalFilesForComponentsWithIDs(r,e)}else e(null)}},{key:"_checkRenditionType",value:function(e,t){if(!e||-1===this._config.VALID_LIBRARY_RENDITION_TYPES.indexOf(e)){if(t)return t(new d(d.INVALID_PARAMETER,"composite rendition type not supported: "+e)),!1;throw new d(d.INVALID_PARAMETER,"composite rendition type not supported: "+e)}return!0}},{key:"_setRenditionFromPath",value:function(e,t,n,i){var o=this;if(!m.checkDeletedState(this,i)){var r=this._dcxCompositeRenditionMap[e],a=t&&this._services.getFileNameFromPath(t),s=this._services.fileUtils.getFileExtension(a),c=this._services.uuid()+"."+s;this._services.fileUtils.checkFileSize(t,(function(s){s?i(s):o._storageInterface.notifyStartWrite(o,[],(function(){o._dcxBranch.addComponent(a,n,"rendition",c,t,!0,void 0,o._dcxNode,void 0,(function(t,n){t?i(t):m.checkDeletedState(o,i)||(n.setValue(o._config.MODIFIED_KEY,Date.now()),n.setValue(o._config.RENDITION_TYPE_KEY,e),r&&o._dcxBranch.removeComponent(r),o._dcxCompositeRenditionMap=m.getCompositeRenditionMap(o._dcxBranch),o._commit(),i(null))}))}))}))}}},{key:"_setRendition",value:function(e,t,n,i,o){var r,a=this,s=this._services.fs,c=function(t){t?o(v.getCommitError(t,a.id,"error writing library rendition")):m.checkDeletedState(a,o)||a._setRenditionFromPath(e,r,i,o)},l=this.collection._getTempDir();this._services.fileUtils.ensurePathExists(l,(function(e){if(e)o(v.getCommitError(e,a.id,"error creating temp directory"));else if(!m.checkDeletedState(a,o)){var u=y.getExtensions(i)[0],h=a._services.uuid()+"."+u;r=l+a._services.getPathSeparator()+h,"buffer"===n?s.writeFile(r,t,c):s.writeFile(r,t,n,c)}}))}},{key:"_setRenditionInBrowser",value:function(e,t,n,i){var o=this,r=this._dcxCompositeRenditionMap[e],a=this._collection._syncManager,s=this._services.uuid();a.uploadNewComponentForLibrary(t,s,n,"rendition",this,(function(t,n){t?i(t):m.checkDeletedState(o,i)||(n.setValue(o._config.MODIFIED_KEY,Date.now()),n.setValue(o._config.RENDITION_TYPE_KEY,e),r&&o._dcxBranch.removeComponent(r),o._dcxCompositeRenditionMap=m.getCompositeRenditionMap(o._dcxBranch),o._commit(),i(null))}))}},{key:"_getFilterKey",value:function(e){return e&&-1!==this._config.ELEMENT_TYPE_FILTERS.indexOf(e)?e:"*"}},{key:"_removeElementFromFilter",value:function(e){var t=this._getFilterKey(e.type);if(this._filterCache[t]){var n=this._filterCache[t].indexOf(e);-1!==n&&this._filterCache[t].splice(n,1)}}},{key:"_addElementToFilter",value:function(e){var t=this._getFilterKey(e.type);this._filterCache[t]=this._filterCache[t]||[],this._filterCache[t].push(e)}},{key:"_doCreateGroup",value:function(e,t,n){var i=this._getGroupsNode(),o=this._dcxBranch.addChild(e,void 0,void 0,i);o.type=this._config.GROUP_TYPE,o.setValue(this._config.CLASSIFIER_KEY,n),o.setValue(this._config.ORDER_KEY,t);var r=new h(this,o);return r._updateCreatedTime(),this._groups.push(r),r}},{key:"_doRemoveGroup",value:function(e,t){var n=this._groups.indexOf(e);this._groups.splice(n,1),this.elements.slice().forEach((function(n){void 0!==n.getOrderInGroup(e)&&(n._doSetOrderInGroup(e,void 0,!0),t&&t(n))})),this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)}},{key:"_getNumberOfElementsInGroup",value:function(e){if(e)return this.elements.reduce((function(t,n){return t+n.getOrderInGroup(e)!==void 0?1:0}),0)}},{key:"_doCopyGroup",value:function(e,t,n,i,o){var r=e.library!==t&&t._groups.every((function(t){return t.id!==e.id}))?e.id:this._services.uuid();this._doCopyDCXGroup(e,t,n,i,r,o)}},{key:"_doCopyDCXGroup",value:function(e,t,n,i,o,r){var a=this;t._beginOperation(),i&&this._beginOperation();var s=function(e){t._endOperation(),i&&a.endOperation(),r(e)};this._storageInterface.notifyStartWrite(t,[this],(function(){var c=t._getGroupsNode();t._dcxBranch.copyChild(e._dcxNode,c,void 0,o,o,(function(o,c){if(!m.checkDeletedState(a,r))if(o)s(o);else{var l=new h(t,c);t._groups.push(l);var u=function(){m.checkDeletedState(a,r)||(t._endOperation(),i&&(a._doRemoveGroup(e),a.endOperation()),r(null,l))};if(n){var p=a.elements.filter((function(t){return void 0!==t.getOrderInGroup(e)})),d=E(a._doCopyElement.bind(a));Promise.all(p.map((function(e){return d(e,t,i)}))).then((function(t){p.forEach((function(n,i){var o=n.getOrderInGroup(e),r=t[i];r._doSetOrderInGroup(l,o,!0),a._analytics.reportCopyElement(r,n)})),u()})).catch(s)}else u()}}))}))}},{key:"_doCreateElement",value:function(e,t){var n=this._dcxBranch.addChild(e,void 0,void 0,this._dcxElementsNode);n.path=n.id,n.type=t;var i=new p(this,n);return i._updateCreatedTime(),this._elements.push(i),this._addElementToFilter(i),i}},{key:"_doRemoveElement",value:function(e,t){var n=this._elements.indexOf(e);-1!==n&&this._elements.splice(n,1),-1!==(n=this._removedElements.indexOf(e))&&this._removedElements.splice(n,1),this._removeElementFromFilter(e),t&&this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)}},{key:"_ensureRemovedElementsSpace",value:function(){for(;this.removedElements.length>=this._config.MAX_REMOVED_ELEMENTS;)this._doRemoveElement(this.removedElements[0],!0)}},{key:"_sortRemovedElements",value:function(){this._removedElements.sort((function(e,t){return e.removed-t.removed}))}},{key:"_doMarkElementRemoved",value:function(e,t){var n=this._elements.indexOf(e);-1!==n&&(this._ensureRemovedElementsSpace(),this._elements.splice(n,1),this._removeElementFromFilter(e),this._removedElements.push(e),this._sortRemovedElements(),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._getRemovedElementsNode()),e._updateTimestampOnRemove()))}},{key:"_doRestoreElement",value:function(e,t){var n=this._removedElements.indexOf(e);-1!==n&&(this._removedElements.splice(n,1),this._elements.push(e),this._addElementToFilter(e),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._dcxElementsNode),e._updateTimestampOnRestore(),e._stripObsoleteGroupsData()))}},{key:"_doCopyDCXNode",value:function(e,t,n,i,o){var r=this;if(this._numActiveCopyNodeOperations<this._config.MAX_DCX_CONCURRENT_COPIES)return this._numActiveCopyNodeOperations++,void e.copyChild(t,n,void 0,i,i,(function(e,t){r._numActiveCopyNodeOperations--,o(e,t),r._pendingCopyNodeOperations.length>0&&r._pendingCopyNodeOperations.shift()()}));this._pendingCopyNodeOperations.push((function(){return r._doCopyDCXNode(e,t,n,i,o)}))}},{key:"_doCopyDCXElement",value:function(e,t,n,i,o){var r=this;t._beginOperation(),this._storageInterface.notifyStartWrite(t,[this],(function(){r._doCopyDCXNode(t._dcxBranch,e._dcxNode,t._dcxElementsNode,i,(function(i,a){if(!m.checkDeletedState(r,o)){if(i)return t._endOperation(),void o(i);var s=new p(t,a);t._addElementToFilter(s),t._elements.push(s),s._stripObsoleteGroupsData();var c=function(){m.checkDeletedState(r,o)||(t._endOperation(),n&&r._wrapOperation((function(){return r._doRemoveElement(e,!0)})),o(null,s))};r._services.hasFileSystem()?t._renditionCache.copyCache(e,s).then(c,c):c()}}))}))}},{key:"_doCopyElement",value:function(e,t,n,i){if(t._elements.length>=this._config.MAX_ELEMENTS)i(new d(d.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+this._config.MAX_ELEMENTS+" elements",this.id));else{var o=e.id;t._elements.every((function(e){return e.id!==o}))&&t._removedElements.every((function(e){return e.id!==o}))||(o=this._services.uuid()),this._doCopyDCXElement(e,t,n,o,i)}}},{key:"jasmineToString",value:function(){return this.toString()}},{key:"toString",value:function(){return JSON.stringify(this._toJSON())}},{key:"_setSyncState",value:function(e){this._syncState!==e&&(this._syncState=e,this._collection._updateSyncState(),this._checkSyncFinishedAndNotify())}},{key:"_isSyncing",value:function(){return void 0!==this._syncState}},{key:"_checkSyncFinishedAndNotify",value:function(){if(!this._isSyncing()){var e=this._waitForSyncToFinishCallbacks;this._waitForSyncToFinishCallbacks=[],e.forEach((function(e){return e()}))}}},{key:"_waitForSyncToFinish",value:function(e){this._waitForSyncToFinishCallbacks.push(e),this._checkSyncFinishedAndNotify()}},{key:"_getClientData",value:function(){var e={};if(this._dcxComposite.clientDataString)try{e=JSON.parse(this._dcxComposite.clientDataString)}catch(e){}return e}},{key:"_getClientDataValue",value:function(e){return this._getClientData()[e]}},{key:"_setClientDataValue",value:function(e,t){var n=this._getClientData();n[e]=t,this._dcxComposite.clientDataString=JSON.stringify(n)}},{key:"_setCollaboration",value:function(e){var t=e&&e.collaboration&&e.collaboration.toLowerCase();if(this.collaboration!==t){var n=m.collaborationStateToDCX(t);this._dcxComposite.collaborationType=n,this._commit(!0,!0),this._notifyChange(),this._revertLocalChangesIfNecessary()}}},{key:"_setAssetId",value:function(e){e&&this._dcxComposite.assetId!==e&&(this._dcxComposite.assetId=e,this._commit(!0,!0))}},{key:"_isDeletedError",value:function(e){var t=e&&(e.code===l.NO_COMPOSITE||e.code===l.DELETED_COMPOSITE),n=e&&e.code===l.UNEXPECTED_RESPONSE&&e.response&&401===e.response.statusCode;return t||this.collection.isPublic&&n}},{key:"_isAlreadyExistsError",value:function(e){var t=e&&e.code===l.ALREADY_EXISTS,n=e&&e.code===l.UNEXPECTED_RESPONSE&&e.response&&409===e.response.statusCode;return t||n}},{key:"_isReadOnlyError",value:function(e){if(!this._collection.isCollaborated)return!1;var t=!1;return!e||e.code!==l.COMPONENT_UPLOAD_ERROR&&e.code!==l.UNEXPECTED_RESPONSE||(e.code===l.UNEXPECTED_RESPONSE&&e.response&&403===e.response.statusCode&&(t=!0),e.code===l.COMPONENT_UPLOAD_ERROR&&Array.isArray(e.failedComponents)&&e.failedComponents.length>0&&(t=!0,e.failedComponents.forEach((function(e){e.error&&e.error.code===l.UNEXPECTED_RESPONSE&&e.error.response&&403===e.error.response.statusCode||(t=!1)})))),t}},{key:"_simpleFieldMerge",value:function(e,t,n,i,o){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[],a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(e){return e},s=t.getValue(e),c=n&&n.getValue(e),l=i&&i.getValue(e),u=a(l);if(u!==a(s))o.setValue(e,s),r.forEach((function(e){return o.setValue(e,t.getValue(e))}));else if(u!==a(c))return o!==n&&(o.setValue(e,c),r.forEach((function(e){return o.setValue(e,n.getValue(e))}))),!0;return!1}},{key:"_mergeAndSwitchToBranch",value:function(e,t,n){var i=this,o=void 0!==t,r=e.localData,a=function(t,a){if(!m.checkDeletedState(i,n))if(t)n(v.getCommitError(t,i.id));else{i._services.log("Starting merge "+(o?"(local)":"(remote)"));var s={},c=function(e){return s[e]=(s[e]||0)+1};a.name!==i.name&&(e.name=i.name);var l=i._config.MODIFIED_KEY,u=a.rootNode.getValue(l)||0,d=e.rootNode.getValue(l)||0,_=i.modified;if(_!==u){var f=d===u?_:Math.max(_,d)+1;e.rootNode.setValue(l,f)}i._simpleFieldMerge(i._config.DOCUMENT_ID_KEY,i._dcxNode,e.rootNode,a.rootNode,e.rootNode),i._simpleFieldMerge(i._config.DOCUMENT_TYPE_KEY,i._dcxNode,e.rootNode,a.rootNode,e.rootNode);var y=function(e){var t={};return m.getCustomDCXData(e.rootNode).forEach((function(e){t[e.namespace+"#"+e.key]=e.value})),t},g={},E=y(i._dcxBranch),O=y(a),A=y(e);Object.keys(E).forEach((function(t){g[t]=!0,JSON.stringify(E[t])!==JSON.stringify(O[t])&&e.rootNode.setValue(t,E[t])})),Object.keys(A).forEach((function(t){g[t]||O[t]&&!E[t]&&e.rootNode.removeValue(t)}));var S,b,L,T=m.getCompositeRenditionMap(e),I=m.getCompositeRenditionMap(a);Object.keys(i._dcxCompositeRenditionMap).forEach((function(t){var n=i._dcxCompositeRenditionMap[t],o=I[t],r=T[t];o&&n.id===o.id||(r?(n.getValue(i._config.MODIFIED_KEY)||0)>(r.getValue(i._config.MODIFIED_KEY)||0)&&(e.removeComponent(r),e.copyComponent(n,e.rootNode)):e.copyComponent(n,e.rootNode))})),Object.keys(I).forEach((function(t){var n=i._dcxCompositeRenditionMap[t],o=I[t],r=T[t];!n&&r&&r.id===o.id&&e.removeComponent(r)})),e.getChildrenOf().forEach((function(e){e.name===i._config.ELEMENTS_NAME&&(S=e),e.name===i._config.REMOVED_ELEMENTS_NAME&&(b=e),e.name===i._config.GROUPS_NAME&&(L=e)})),S||(S=e.addChild(i._config.ELEMENTS_NAME));var C=function(){b||(b=e.addChild(i._config.REMOVED_ELEMENTS_NAME))},R=[],P={},D=[],w=function(e,t,n,o){return[i._simpleFieldMerge("name",t,n,o,e._dcxNode,[i._config.LOCALIZED_NAME_KEY]),i._simpleFieldMerge(i._config.ORDER_KEY,t,n,o,e._dcxNode),i._simpleFieldMerge(i._config.PARENT_KEY,t,n,o,e._dcxNode)].some((function(e){return e}))};i._groups.forEach((function(t){var n=t.id,o=t._dcxNode,r=t.modified,s=e.getChildWithId(n),l=s&&s.getValue(i._config.MODIFIED_KEY),u=a&&a.getChildWithId(n),h=u&&u.getValue(i._config.MODIFIED_KEY);if(!h&&!l||h&&!l&&r!==h){c("g1: group created locally");var p=e.copyChild(o,(L||(L=e.addChild(i._config.GROUPS_NAME)),L),void 0,void 0,void 0);t._setDCXNode(p)}else h&&!l&&r===h?(c("g2: group deleted on server"),D.push(t)):h===r&&h===l?(c("g3: no changes to group modified time"),t._setDCXNode(s),w(t,o,s,u)&&R.push(t)):h===r&&h!==l?(c("g4: updated group on server"),t._setDCXNode(s),R.push(t),w(t,o,s,u)):h!==r&&h===l?(c("g5: updated group locally"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),w(t,o,s,u)&&R.push(t)):h!==r&&h!==l?(c("g6: updated group locally and on server (conflict)"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),w(t,o,s,u)&&R.push(t)):i._services.log("ERROR: unexpected group merge case: base="+h+", current="+r+", pulled="+l);P[n]=!0})),D.forEach((function(e){return i._doRemoveGroup(e)}));var N=[],k=[],x=[],M=[],F=[],U=function(t){var n=t.id,r=t._dcxNode,s=t.modified,l=t.removed,u=e.getChildWithId(n),h=u&&u.getValue(i._config.MODIFIED_KEY),d=u&&u.getValue(i._config.REMOVED_KEY),_=a&&a.getChildWithId(n),f=_&&_.getValue(i._config.MODIFIED_KEY),m=_&&_.getValue(i._config.REMOVED_KEY);i._dcxBranch=e;var v=function(){return l?(C(),b):S},y=function(){return!l&&t.removed?(x.push(t),!0):!(!l||t.removed||(M.push(t),0))},g=function(){var e=[i._simpleFieldMerge("name",r,u,_,t._dcxNode,[i._config.AUTO_NAMED_KEY,i._config.LOCALIZED_NAME_KEY]),i._simpleFieldMerge("tags",r,u,_,t._dcxNode),i._simpleFieldMerge(i._config.SOURCE_REF_KEY,r,u,_,t._dcxNode),i._simpleFieldMerge(i._config.DEPENDENCIES_KEY,r,u,_,t._dcxNode,[],(function(e){return JSON.stringify(e)}))].some((function(e){return e})),n=r.getValue(i._config.DESCRIPTION_DATA_KEY)||{time:0},o=u&&u.getValue(i._config.DESCRIPTION_DATA_KEY)||{time:0},a=_&&_.getValue(i._config.DESCRIPTION_DATA_KEY)||{time:0};if(n.time!==a.time){var s=r.getValue(i._config.DESCRIPTION_KEY);t._dcxNode.setValue(i._config.DESCRIPTION_KEY,s),t._dcxNode.setValue(i._config.DESCRIPTION_DATA_KEY,n)}else o.time!==a.time&&(e=!0);var c=r.getValue(i._config.GROUPS_KEY)||{},l=u&&u.getValue(i._config.GROUPS_KEY)||{},h=_&&_.getValue(i._config.GROUPS_KEY)||{},p={};return Object.keys(c).forEach((function(t){var n=c[t],i=l[t],o=h[t];o&&n.order===o.order?i||(e=!0):p[t]=n})),Object.keys(l).forEach((function(t){var n=c[t],i=l[t],o=h[t];o&&!n||p[t]||(p[t]=i,o&&i.order===o.order||(e=!0))})),(Object.keys(p).length>0||Object.keys(l).length>0)&&JSON.stringify(l)!==JSON.stringify(p)&&t._dcxNode.setValue(i._config.GROUPS_KEY,p),e};if(!f&&!h||f&&!h&&s!==f){c("e1: created element locally");var E=e.copyChild(r,v(),void 0,void 0,void 0);t._setDCXNode(E,!0)}else if(f&&!h&&s===f)c("e2: deleted element on server"),k.push(t);else if(f===s&&f===h){c("e3: no changes to element modified time"),t._setDCXNode(u,!0),m!==l&&(m===d?l&&!d?(c("e3a: removed element locally"),C(),t._dcxNode=e.moveChild(t._dcxNode,void 0,b),t._updateTimestampOnRemove(l)):d&&!l&&(c("e3b: restored element locally"),t._dcxNode=e.moveChild(t._dcxNode,void 0,S),t._updateTimestampOnRestore()):l||(c("e3c: remove/restore element conflict - local restore wins"),t._dcxNode=e.moveChild(t._dcxNode,void 0,S),t._updateTimestampOnRestore()));var O=y(),A=g();(O||A)&&R.push(t),t._ensureRemovedDataValid(o&&!i._config.SHARED_LOCAL_STORAGE)}else if(f===s&&f!==h)c("e4: updated element on server"),t._setDCXNode(u,o),R.push(t),y(),g(),t._ensureModifiedDataValid(o&&!i._config.SHARED_LOCAL_STORAGE);else if(f!==s&&f===h){c("e5: updated element locally");var L=e.replaceChild(r,void 0,void 0);t._setDCXNode(L,!0),(l&&!d||d&&!l)&&(t._dcxNode=e.moveChild(t._dcxNode,void 0,v())),g()&&R.push(t)}else if(f!==s&&f!==h){c("e6: updated element locally and on server (conflict)"),t._setDCXNode(u),R.push(t),y(),t._ensureModifiedDataValid(o&&!i._config.SHARED_LOCAL_STORAGE);var T=i._services.uuid(),I=e.copyChild(r,v(),void 0,T,T),D=new p(i,I);N.push(D),P[D.id]=!0,i._services.hasFileSystem()&&F.push((function(e){return i._renditionCache.copyCache(t,D).then(e,e)})),i._analytics.reportCollisionElement(t)}else i._services.log("ERROR: unexpected element merge case: base="+f+", current="+s+", pulled="+h);i._dcxBranch=i._dcxComposite.current,P[n]=!0};i._elements.forEach(U),i._removedElements.forEach(U);var H=function(e){e.removed?i._removedElements.push(e):(i._addElementToFilter(e),i._elements.push(e))};N.forEach(H),i._sortRemovedElements(),k.forEach((function(e){return i._doRemoveElement(e,!1)})),x.forEach((function(e){return i._doMarkElementRemoved(e,!1)})),M.forEach((function(e){return i._doRestoreElement(e,!1)})),i._dcxBranch=e,i._dcxElementsNode=S,i._dcxRemovedElementsNode=b,i._dcxGroupsNode=L,i._dcxCompositeRenditionMap=m.getCompositeRenditionMap(e);var V=function(t,n){if(!P[t.id]){var r=t.getValue(i._config.MODIFIED_KEY),s=a&&a.getChildWithId(t.id),l=s&&s.getValue(i._config.MODIFIED_KEY);if(l&&r&&l===r)c(n?"g7: deleted group locally":"e7: deleted element locally"),e.removeChild(t);else if(c(n?"g8: created group on server":"e8: created element on server"),n){var u=new h(i,t);i._groups.push(u)}else{var d=new p(i,t);H(d),d._ensureCreatedDataValid(o&&!i._config.SHARED_LOCAL_STORAGE)}}},B=i._dcxBranch.getChildrenOf(i._dcxElementsNode),j=i._dcxRemovedElementsNode?i._dcxBranch.getChildrenOf(i._dcxRemovedElementsNode):[],Y=i._dcxGroupsNode?i._dcxBranch.getChildrenOf(i._dcxGroupsNode):[];B.forEach((function(e){return V(e)})),j.forEach((function(e){return V(e)})),Y.forEach((function(e){return V(e,!0)})),Object.keys(s).sort().forEach((function(e){var t=s[e];i._services.log("Merge Case ".concat(e," (").concat(t,")"))})),i._transactionCount++,Promise.all(F.map((function(e){return new Promise((function(t){return e(t)}))}))).then((function(){m.checkDeletedState(i,n)||(i._transactionCount--,i._storageInterface.resolvePullWithBranch(i,e,r,o,(function(t){m.checkDeletedState(i,n)||(t?n(v.getCommitError(t,i.id)):(i._services.hasFileSystem()||(i._dcxBaseBranch=e.copy()),i._config.SHARED_LOCAL_STORAGE||o||i._prefetchRenditions(),n(null),R.forEach((function(e){return e._listenerManager.notify("change")})),i._notifyChange()))})))}))}};this._waitForCommit((function(){m.checkDeletedState(i,n)||(t?a(null,t):"unmodified"===i._dcxBranch.compositeState?a(null,i._dcxBranch):i._loadBaseBranch(a))}))}},{key:"_pull",value:function(e){var t=this;if(this._dcxComposite.href&&this._dcxBranch.isBound)if(this._deletedFromServer)e(null,!1);else{var n=function(n,i){m.checkDeletedState(t,e)||(n&&t._collection._reportSyncError(n),t._setSyncState(),t._networkLock.release(),e(n,i))};this._networkLock.obtain((function(i){i?e(null):m.checkDeletedState(t,e)||(t._setSyncState("downloading"),t._collection._syncManager.pullLibrary(t,(function(i,o){m.checkDeletedState(t,e)||(t._isDeletedError(i)?t._services.hasFileSystem()&&"modified"===t._dcxBranch.compositeState&&t._collection.isPrivate?(t._doRebindToServer(!1,e),t._networkLock.release()):(t._deletedFromServer=!0,t._notifyChange(),n(null,!0)):i?n(v.getSyncError(i,t.id)):o?t._mergeAndSwitchToBranch(o,void 0,(function(i){m.checkDeletedState(t,e)||n(i,!0)})):n(null,!1))})))}))}else e(null,!1)}},{key:"_pushWithParameters",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},i=!this._dcxComposite.isBound,o=function(e,o){n(null,o),t.collection._onLibraryPush&&t.collection._onLibraryPush(t,i&&o)};if(this._config.SYNCING_ENABLED)if(this._collection._retryTimeoutId)o(null,!1);else if(this._dcxBranch.isBound&&"modified"!==this._dcxBranch.compositeState)o(null,!1);else if(this._deletedFromServer)o(null,!1);else if(this.isWritable)if(this._pushPending)o(null,!1);else{var r=function(e,i){m.checkDeletedState(t,o)||(t._pushFailedDueToQuota=!1,e&&(t._collection._reportSyncError(e),e.code===d.EXCEEDS_QUOTA&&(t._pushFailedDueToQuota=!0)),t._setSyncState(),t._collection._syncManager.pullMissingComponents(t,(function(){m.checkDeletedState(t,n)||(t._networkLock.release(),t._prefetchRenditions(),o(null,i))})))};this._pushPending=!0,this._networkLock.obtain((function(n){n?o(null,!1):t._waitForCommit((function(){var n;m.checkDeletedState(t,o)||(t._pushPending=!1,t._services.hasFileSystem()||(n=t._dcxBranch.copy()),t._setSyncState("uploading"),t._collection._syncManager.pushLibrary(t,e,(function(e){if(!m.checkDeletedState(t,o))if(t._isDeletedError(e))t._services.hasFileSystem()&&"modified"===t._dcxBranch.compositeState&&t._collection.isPrivate?(t._doRebindToServer(!1,o),t._networkLock.release()):(t._deletedFromServer=!0,t._notifyChange(),r(null,!0));else{if(t._isAlreadyExistsError(e)){var i=t._localisation.translate("LIBS_RECOVERED_LIBRARY",{name:""}),a=t._collection._recoveredLibraryCount>t._config.MAX_RECOVERED_LIBRARIES;if(t._getRawName().endsWith(i)||a){var s=a?"count exceeded":"already recovered";return t._services.log("Failed to recover library ".concat(s,": ").concat(t.id)),void r(v.getSyncError(e,t.id))}return t._setName(t._localisation.translate("LIBS_RECOVERED_LIBRARY",{name:t._getRawName()})),t._services.log("Recovering library due to 409 error: ".concat(t.id)),t._collection._recoveredLibraryCount++,t._doRebindToServer(!0,o),void t._networkLock.release()}if(t._isReadOnlyError(e))return t._services.log("Push failed due to read only. Reverting: "+t.id),t._dcxComposite.isWritable=!1,void t._revertLocalChangesIfNecessary((function(e){return r(e,!1)}));if(e&&e.code===d.TRANSFER_ABORTED)r(null,!0);else{if(e&&e.code===l.UPDATE_CONFLICT){if(t._services.log("Push failed due to conflict: "+t.id),t._numUpdateConflicts++,t._numUpdateConflicts<=t._config.MAX_UPDATE_CONFLICTS)return t._sync(!1,o),void t._networkLock.release();t._analytics.reportUnexpectedState(t,"updateConflict"),t._services.log("Reached maximum number of update-conflict retries: "+t.id)}t._numUpdateConflicts=0,e&&e.code===l.COMPONENT_UPLOAD_ERROR&&(t._services.log("Push failed due to component upload failure: "+t.id),m.fixLocalComponents(t,e.failedComponents)),e?r(v.getSyncError(e,t.id)):t._storageInterface.acceptPush(t,(function(e){m.checkDeletedState(t,o)||(e?r(v.getCommitError(e,t.id),!0):(t._services.hasFileSystem()||(t._dcxBaseBranch=n),r(null,!0)))}))}}})))}))}))}else o(null,!1);else o(null,!1)}},{key:"_loadBaseBranch",value:function(e){var t=this;this._services.hasFileSystem()?this._dcxComposite.loadBaseBranch((function(n,i){t._waitForCommit((function(){return e(n,i)}))})):e(null,this._dcxBaseBranch)}},{key:"_revertLocalChangesIfNecessary",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this.isWritable||"modified"!==this._dcxBranch.compositeState?t(null):this._loadBaseBranch((function(n,i){e._transactionCount++,m.recoverReadOnlyEdits(e,i,(function(n){n&&e._services.log("Error recovering library changes: "+n),e._transactionCount--;var o=i.copy(),r=e.collaboration,a=e._dcxComposite.isWritable;e._mergeAndSwitchToBranch(o,e._dcxBranch,(function(n){if(n)e._services.log("Error Reverting: "+e.id),t(n);else{var i=m.collaborationStateToDCX(r);e._dcxComposite.collaborationType=i,e._dcxComposite.isWritable=a,e._commit(!0,!0),e._waitForCommit((function(){e._notifyChange(),t(null)}))}}))}))}))}},{key:"_push",value:function(e){this._pushWithParameters(!1,e)}},{key:"_abortPushOrPull",value:function(){this._networkLock.abortPendingOperations(new d(d.TRANSFER_ABORTED)),this._collection._syncManager.abortPushOrPull(this.id)}},{key:"_deleteFromServer",value:function(e,t){var n=this;if(this._deletingFromServerInProgress||this._abortPushOrPull(),this._dcxComposite.href)if(this._deletedFromServer)t(null);else{this._deletingFromServerInProgress=!0;var i=function(e){n._deletingFromServerInProgress=!1,n._setSyncState(),n._networkLock.release(),t(e)};this._networkLock.obtain((function(o){o?t(null):n._deletedFromDisk?i(null):(n._setSyncState("uploading"),n._collection._prepareCompositeForDelete(n._dcxComposite),n._commit(!0,!0),n._waitForCommit((function(){n._deletedFromDisk?i(null):n._collection._syncManager.pushDeletedLibrary(n,n.collaboration,e,(function(t){t?n._isDeletedError(t)?(n._deletedFromServer=!0,t=null):(e||t.code!==l.UPDATE_CONFLICT)&&(t=v.getSyncError(t,n.id),n._collection._reportSyncError(t)):n._deletedFromServer=!0,i(t)}))})))}))}else t(null)}},{key:"_doRebindToServer",value:function(e,t){var n=this;this._deletedFromServer=!1;var i=e||"incoming"===this.collaboration?"resetIdentity":"resetBinding",o=this.id;this._dcxComposite[i]((function(e){m.checkDeletedState(n,t)||(e?t(e):(n._transactionCount++,n.id!==o&&(n._collection._libraryIdMap[n.id]=n,delete n._collection._libraryIdMap[o]),n._services.fileUtils.moveLibrary(n,o,(function(e){m.checkDeletedState(n,t)||(n._transactionCount--,e?t(e):(n._collection._prepareCompositeForPush(n._dcxComposite),n._setCollaboration(),n._commit(!1,!0),n._pushWithParameters(!0,t)))}))))}))}},{key:"_sync",value:function(e,t){var n=this,i=function(e,i){t&&n._waitForSyncToFinish((function(){return t(e,i)}))};if(!this._config.SHARED_LOCAL_STORAGE&&this._config.SYNCING_ENABLED)if(this._collection._retryTimeoutId)i(null,!1);else{this._collection._clearSyncErrors(this.id);var o=function(e,t){m.checkDeletedState(n,i)||(e?i(e,t):n._push((function(e,o){m.checkDeletedState(n,i)||i(e,t||o)})))};e?o(null,!1):this._pull(o)}else i(null,!1)}},{key:"_getCompositeDir",value:function(){return this._collection._getCompositeDir(this.id)}},{key:"_getRenditionCacheDir",value:function(){return this._collection._getRenditionCacheDir(this.id)}},{key:"_setAutoGC",value:function(e,t){!1===t?this._autoGCMode[e]=!1:delete this._autoGCMode[e],this._dcxComposite.autoRemoveUnusedLocalFiles=0===Object.keys(this._autoGCMode)}},{key:"_prefetchRenditions",value:function(){return this._services.hasFileSystem()?Promise.all(this.elements.map((function(e){return e._prefetchRenditions()}))):Promise.resolve()}},{key:"_getActions",value:function(e){if(!this.documentType)return[];var t=this._config.DOCUMENT_LIBRARY_ACTION_PRODUCT_MAP,n=t.types[this.documentType]||[];return this._constructActions(e,n,t,_)}},{key:"getGroups",value:function(e){return e=e||this._config.DEFAULT_GROUP_CLASSIFIER,this._groups.filter((function(t){return e instanceof RegExp?e.test(t.classifierName):e===t.classifierName}))}},{key:"getGroupById",value:function(e){return this._groups.find((function(t){return t.id===e}))}},{key:"createGroup",value:function(e,t,n){if(n=n||this._config.DEFAULT_GROUP_CLASSIFIER,m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);var i=this._doCreateGroup(e,t,n);return this._commit(),this._analytics.reportCreateGroup(i),i}},{key:"removeGroup",value:function(e,t,n){var i=this;if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new d(d.INVALID_PARAMETER,"No group specified",this.id);if(-1===this._groups.indexOf(e))throw new d(d.INVALID_PARAMETER,"group not in this library",this.id);var o=0;this._doRemoveGroup(e,(function(e){t?(i.removeElement(e,n),o++):e._listenerManager.notify("change")})),this._commit(),this._analytics.reportDeleteGroup(e,t,o)}},{key:"moveGroup",value:function(e,t,n,i){var o=this;if(!m.checkDeletedState(this,i))if(this.isWritable)if(e)if(-1!==this._groups.indexOf(e))if(t)if(this!==t){if(t.isWritable){var r=n?this._getNumberOfElementsInGroup(e):void 0;return this._doCopyGroup(e,t,n,!0,(function(t,a){t?i(t):(o._analytics.reportMoveGroup(a,e,n,r),i(null,a))}))}i(new d(d.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else i(new d(d.INVALID_PARAMETER,"Move must have a different destination library",this.id));else i(new d(d.INVALID_PARAMETER,"No destination library specified",this.id));else i(new d(d.INVALID_PARAMETER,"Group not in this library",this.id));else i(new d(d.INVALID_PARAMETER,"No group specified",this.id));else i(new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id))}},{key:"copyGroup",value:function(e,t,n,i){var o=this;if(!m.checkDeletedState(this,i))if(e)if(-1!==this._groups.indexOf(e))if(t){if(t.isWritable){var r=n?this._getNumberOfElementsInGroup(e):void 0;return this._doCopyGroup(e,t,n,!1,(function(t,a){t?i(t):(o._analytics.reportCopyGroup(a,e,n,r),i(null,a))}))}i(new d(d.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else i(new d(d.INVALID_PARAMETER,"No destination library specified",this.id));else i(new d(d.INVALID_PARAMETER,"Group not in this library",this.id));else i(new d(d.INVALID_PARAMETER,"No group specified",this.id))}},{key:"createElement",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);var o=((i=i&&t===this._config.COLOR_ELEMENT_TYPE)?2:1)*this._config.MAX_ELEMENTS;if(this._elements.length>=o)throw new d(d.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+this._config.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation((function(){var i=n._doCreateElement(e,t);return n._analytics.reportCreateElement(i),i.beginOperation(),i}))}},{key:"removeElement",value:function(e,t){var n=this;if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new d(d.INVALID_PARAMETER,"No element specified",this.id);if(-1===this._elements.indexOf(e)){if(-1===this._removedElements.indexOf(e))throw new d(d.INVALID_PARAMETER,"Element not in this library",this.id);if(!t)throw new d(d.INVALID_PARAMETER,"Element already removed",this.id)}return this._wrapOperation((function(){for(;e._transactionCount>0;)e.endOperation();t?n._doRemoveElement(e,!0):n._doMarkElementRemoved(e,!0),n._analytics.reportDeleteElement(e,t)}))}},{key:"restoreElement",value:function(e){var t=this;if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new d(d.INVALID_PARAMETER,"No element specified",this.id);if(-1===this._removedElements.indexOf(e)){if(-1===this._elements.indexOf(e))throw new d(d.INVALID_PARAMETER,"Element not in this library",this.id);throw new d(d.INVALID_PARAMETER,"Element already restored",this.id)}if(this._elements.length>=this._config.MAX_ELEMENTS)throw new d(d.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+this._config.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation((function(){t._doRestoreElement(e,!0),t._analytics.reportRestoreElement(e)}))}},{key:"copyElement",value:function(e,t,n){var i=this;if(!m.checkDeletedState(this,n))if(e)if(-1!==this._elements.indexOf(e)||-1!==this._removedElements.indexOf(e))if(t){if(t.isWritable)return this._doCopyElement(e,t,!1,(function(t,o){t?n(t):(i._analytics.reportCopyElement(o,e),n(null,o))}));n(new d(d.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else n(new d(d.INVALID_PARAMETER,"No destination library specified",this.id));else n(new d(d.INVALID_PARAMETER,"Element not in this library",this.id));else n(new d(d.INVALID_PARAMETER,"No element specified",this.id))}},{key:"moveElement",value:function(e,t,n){var i=this;if(!m.checkDeletedState(this,n))if(this.isWritable)if(e)if(-1!==this._elements.indexOf(e)||-1!==this._removedElements.indexOf(e))if(t)if(this!==t){if(t.isWritable)return this._doCopyElement(e,t,!0,(function(t,o){t?n(t):(i._analytics.reportMoveElement(o,e),n(null,o))}));n(new d(d.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else n(new d(d.INVALID_PARAMETER,"Move must have a different destination library",this.id));else n(new d(d.INVALID_PARAMETER,"No destination library specified",this.id));else n(new d(d.INVALID_PARAMETER,"Element not in this library",this.id));else n(new d(d.INVALID_PARAMETER,"No element specified",this.id));else n(new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id))}},{key:"getValues",value:function(){return m.getCustomDCXData(this._dcxNode)}},{key:"setValue",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);if(e===this._config.DL_NAMESPACE)throw new d(d.INVALID_PARAMETER,"Reserved namespace",this.id);var o,r=m.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new d(d.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.id)}this._dcxNode.setValue(r,o),this._commit(!1,i)}},{key:"getValue",value:function(e,t){if(e===this._config.DL_NAMESPACE)throw new d(d.INVALID_PARAMETER,"Reserved namespace",this.id);var n=m.getDCXKey(e,t);return this._dcxNode.getValue(n)}},{key:"removeValue",value:function(e,t){if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);if(e===this._config.DL_NAMESPACE)throw new d(d.INVALID_PARAMETER,"Reserved namespace",this.id);var n=m.getDCXKey(e,t);this._dcxNode.removeValue(n),this._commit()}},{key:"linkToDocument",value:function(e,t){var n=this;if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e&&!t)return this._wrapOperation((function(){n._dcxNode.removeValue(n._config.DOCUMENT_ID_KEY),n._dcxNode.removeValue(n._config.DOCUMENT_TYPE_KEY)}));if("string"!=typeof e||"string"!=typeof t)throw new d(d.INVALID_PARAMETER,"document id and type must be strings",this.id);this._wrapOperation((function(){n._dcxNode.setValue(n._config.DOCUMENT_ID_KEY,e),n._dcxNode.setValue(n._config.DOCUMENT_TYPE_KEY,t)}))}},{key:"getActions",value:function(e){if(!this._config.SHARED_LOCAL_STORAGE)throw new d(d.NOT_SUPPORTED,"getActions() not supported without shared local storage");if(e&&-1===this._config.LIBRARY_ACTIONS.indexOf(e))throw new d(d.INVALID_PARAMETER,"Unknown id supplied. Potential ids are",this._config.LIBRARY_ACTIONS.join(", "));return this._getActions(e)}},{key:"getRenditionPath",value:function(e,t){var n=this;if(this._services.hasFileSystem()){if(!m.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var i=this._dcxCompositeRenditionMap[e];if(!i)return t(null);var o=this._dcxBranch.assetOfComponent(i);if(o)return t(null,o);this._networkLock.obtain((function(e){e?t(e):m.checkDeletedState(n,t)?n._networkLock.release():(n._setSyncState("downloading"),n._collection._syncManager.downloadComponent(n._dcxBranch,i,(function(e){n._networkLock.release(),n._setSyncState(),e?t(v.getSyncError(e,n.id)):m.checkDeletedState(n,t)||(n._commit(!0,!0),t(null,n._dcxBranch.assetOfComponent(i)))})))}))}}else t(new d(d.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id))}},{key:"getRenditionURL",value:function(e){m.checkDeletedState(this),this._checkRenditionType(e);var t=this._dcxCompositeRenditionMap[e];if(t)return this._collection._syncManager.getContentURL(t)}},{key:"getAuthenticatedRenditionURL",value:function(e,t){if(!m.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var n=this.getRenditionURL(e);if(!n)return t(null);this._collection._syncManager.appendAccessTokenToURL(n,t)}}},{key:"setRendition",value:function(e,t,n,i,o){if(!m.checkDeletedState(this,o)&&this._checkRenditionType(e,o))if(t)if(this.isWritable)if(this._services.hasFileSystem()){if(!m.checkEncoding(n,["utf8","ascii","base64","buffer"],o))return;this._setRendition(e,t,n,i,o)}else{if(void 0!==n)return void o(new d(d.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setRenditionInBrowser(e,t,i,o)}else o(new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id));else o(new d(d.INVALID_PARAMETER,"content must exist",this.id))}},{key:"setRenditionFromPath",value:function(e,t,n,i){m.checkDeletedState(this,i)||this._checkRenditionType(e,i)&&("string"==typeof t?this._services.hasFileSystem()?this.isWritable?this._setRenditionFromPath(e,t,n,i):i(new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id)):i(new d(d.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id)):i(new d(d.INVALID_PARAMETER,"path must be a string",this.id)))}},{key:"removeRendition",value:function(e){var t=this;if(m.checkDeletedState(this),this._checkRenditionType(e),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);var n=this._dcxCompositeRenditionMap[e];if(n)return this._wrapOperation((function(){t._dcxBranch.removeComponent(n),t._dcxCompositeRenditionMap=m.getCompositeRenditionMap(t._dcxBranch)}))}},{key:"beginOperation",value:function(){if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);this._beginOperation()}},{key:"endOperation",value:function(){if(m.checkDeletedState(this),!this.isWritable)throw new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id);this._endOperation()}},{key:"getFilteredElements",value:function(e){if(!e)throw new d(d.INVALID_PARAMETER,"must specify element type to filter",this.id);if("*"!==e&&-1===this._config.ELEMENT_TYPE_FILTERS.indexOf(e))throw new d(d.INVALID_PARAMETER,"must specify '*', or an element type in config.ELEMENT_TYPE_FILTERS",this.id);var t=this._getFilterKey(e);return this._filterCache[t]=this._filterCache[t]||[],this._filterCache[t]}},{key:"sync",value:function(e){m.checkDeletedState(this,e)||this._sync(!1,e)}},{key:"rebindToServer",value:function(e){this._services.hasFileSystem()?m.checkDeletedState(this,e)||(this.isWritable?this._deletedFromServer?this._doRebindToServer(!1,e):e(null):e(new d(d.NOT_ALLOWED,"you do not have write access to this library",this.id))):e(new d(d.REQUIRES_FILESYSTEM,"rebindToServer requires a filesystem",this.id))}},{key:"getElementById",value:function(e,t){var n=this.elements.find((function(t){return t.id===e}));return n||t?n:this.removedElements.find((function(t){return t.id===e}))}},{key:"getElementsAndDependencies",value:function(e){var t=this,n={};this.elements.forEach((function(e){return n[e.id]=e}));var i={};return e.forEach((function(e){return function e(o){var r=n[o];r&&!i[o]&&(i[o]=r,(r._dcxNode.getValue(t._config.DEPENDENCIES_KEY)||[]).forEach(e))}(e.id)})),Object.keys(i).map((function(e){return i[e]}))}},{key:"_updateStorageUsed",value:function(){var e=this._dcxComposite._current;if(e){var t=e._core._recursivelyGetAllComponentsOfChild(e.rootNode);this._storageUsed=t.reduce((function(e,t){return e+t.length}),0)+e.remoteData.length}}},{key:"_services",get:function(){return this._collection._services}},{key:"_config",get:function(){return this._collection._config}},{key:"_analytics",get:function(){return this._collection._analytics}},{key:"_storageInterface",get:function(){return this._collection._storageInterface}},{key:"_localisation",get:function(){return this._collection._localisation}},{key:"_dcxNode",get:function(){return this._dcxBranch.rootNode}},{key:"id",get:function(){return this._publicId||this._dcxComposite.id}},{key:"assetId",get:function(){return this._dcxComposite.assetId}},{key:"collection",get:function(){return this._collection}},{key:"isWritable",get:function(){return void 0===this._dcxComposite.isWritable?!this._publicId:this._dcxComposite.isWritable}},{key:"isParentWritable",get:function(){return this._dcxComposite.isParentWritable}},{key:"owner",get:function(){return this._dcxComposite.storageAssignee&&this._dcxComposite.storageAssignee.id}},{key:"ownerType",get:function(){return this._dcxComposite.storageAssignee&&this._dcxComposite.storageAssignee.type}},{key:"parentDirectoryId",get:function(){return this._dcxComposite.parentAssetId}},{key:"isPushedToServer",get:function(){return this._dcxComposite.isBound}},{key:"elements",get:function(){return this._elements}},{key:"removedElements",get:function(){return this._removedElements}},{key:"isDeletedFromServer",get:function(){return this._deletedFromServer}},{key:"isDeletedLocally",get:function(){return this._deletedLocally}},{key:"isQuotaExceeded",get:function(){return this._pushFailedDueToQuota}},{key:"toolkitId",get:function(){return this.getValue(this._config.TOOLKIT_NAMESPACE,this._config.TOOLKIT_ID_KEY)}},{key:"documentId",get:function(){return this._dcxNode.getValue(this._config.DOCUMENT_ID_KEY)}},{key:"documentType",get:function(){return this._dcxNode.getValue(this._config.DOCUMENT_TYPE_KEY)}},{key:"collaboration",get:function(){var e=this._dcxComposite.collaborationType;return m.collaborationStateFromDCX(e)}},{key:"syncState",get:function(){return this._syncState}},{key:"syncProgress",get:function(){var e=this._collection._syncProgressMap[this.id];return e&&e.progress}},{key:"storageUsed",get:function(){return this._storageUsed||0}}])&&o(n.prototype,u),t}(u);e.exports=O},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function h(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var d=n(78),_=n(79),f=n(38),m=n(1),v=["public","collab"],y=function(e){function t(e){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,t),(n=c(this,l(t).call(this,e._config.BOOKMARKS_FILENAME,e)))._disableSyncing=i.DISABLE_SYNCING,n._bookmarks=[],n._bookmarkData=[],n._queuedOperations=[],n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(t,e),h(t,null,[{key:"waitForPushNew",value:function(e){return{condition:"on_pushed_new",libraryId:e}}},{key:"waitForDelete",value:function(e){return{condition:"on_deleted",libraryId:e}}}]),h(t,[{key:"_toJSON",value:function(){return{version:this._config.BOOKMARKS_FILE_VERSION,bookmark_data:this._bookmarkData,queued_operations:this._queuedOperations,bookmarks:this._bookmarks.filter((function(e){return"public"===e.type})).map((function(e){return{id:e.id,url:e.url}})),etag:'"0"'}}},{key:"_fromJSON",value:function(e){if(!e||e.version&&e.version!==this._config.BOOKMARKS_FILE_VERSION)return this._services.log("Unsupported bookmarks.json file - ignoring"),void(this._bookmarkData=[]);e.version||(this._services.log("Legacy bookmarks.json file - migrating"),e.bookmark_data=e.bookmarks.map((function(e){return r({type:"public"},e)}))),this._bookmarkData=e.bookmark_data,this._queuedOperations=e.queued_operations||[],this._ensureBookmarks()}},{key:"_serialize",value:function(e){return this._config.isNewBookmarkFormatSupported(e)?this._toJSON():this._bookmarks.filter((function(e){return"public"===e.type})).map((function(e){return{_id:e.id,_url:e.url}}))}},{key:"_deserialize",value:function(e){this._fromJSON(e)}},{key:"_checkAndApplyCondition",value:function(e){var t=e.condition&&e.condition.condition,n=e.condition&&e.condition.libraryId,i=this._collection._apiRoot.getLoadedCollections().reduce((function(e,t){return e||!t.isPrivate&&t._getLocalLibraryById(n)}),null);return"on_pushed_new"===t&&i&&i._dcxBranch&&i._dcxBranch.compositeAssetId?(e.data.urn=i._dcxBranch.compositeAssetId,delete e.condition,!0):"on_deleted"===t&&!i&&(delete e.condition,!0)}},{key:"_isConditionStale",value:function(e){var t=e.condition&&e.condition.condition,n=e.condition&&e.condition.libraryId,i=n&&this._collection._apiRoot.getLibraryById(n);return"on_pushed_new"===t&&!i||"on_deleted"===t&&i}},{key:"_checkAndApplyConditions",value:function(){var e=this,t=this._queuedOperations.filter((function(t){return!e._isConditionStale(t)})),n=t.reduce((function(t,n){return e._checkAndApplyCondition(n)||t}),!1)||t.length!==this._queuedOperations.length;return this._queuedOperations=t,n}},{key:"_pushOperation",value:function(e){if("remove"===e.operation){var t=this._queuedOperations.findIndex((function(t){return"create"===t.operation&&t.data&&t.data.id===e.id}));if(t>=(this._isPushing?1:0))return void this._queuedOperations.splice(t,1)}this._queuedOperations.push(e)}},{key:"_ensureBookmarks",value:function(){var e=this,t={};this._bookmarks.forEach((function(e){return t[e.id]=e}));var n={},i=[];this._queuedOperations.forEach((function(e){"remove"===e.operation?n[e.id]=!0:"create"===e.operation&&("team"===e.data.type&&(e.data.type="collab"),i.push(e.data))})),this._bookmarks=[];var o=function(i){if(v.includes(i.type)&&!n[i.id]){var o=t[i.id],r=function(t){o&&o._onRemove&&(t._onRemove=o._onRemove),e._bookmarks.push(t)};t[i.id]&&delete t[i.id],"public"===i.type?r(new d(i.id,i.url)):"collab"===i.type&&r(new _(i.id,i.urn,i.role))}};this._bookmarkData.forEach(o),i.forEach(o),Object.keys(t).forEach((function(e){var n=t[e];n._onRemove&&n._onRemove()})),this._services.log("Notifying bookmarks change: ".concat(this._bookmarks.join(", "))),this._listenerManager.notify("change")}},{key:"_saveAndPushChanges",value:function(){var e=this;return this._ensureBookmarks(),this._lock.execute((function(){return e._save().then((function(){return!e._disableSyncing&&e._push()}))}))}},{key:"_sync",value:function(){var e=this;return this._disableSyncing?Promise.reject(new m(m.NOT_ALLOWED,"Syncing is disabled on this instance of the bookmark manager")):this._push().then((function(){return e._pull()}))}},{key:"_pull",value:function(){var e=this;return this._syncManager.getBookmarks().then((function(t){return e._bookmarkData=t&&t.bookmarks||[],e._ensureBookmarks(),e._save()})).catch((function(t){return e._collection._reportSyncError(t)}))}},{key:"_push",value:function(){var e=this;if(this._checkAndApplyConditions())return this._ensureBookmarks(),this._save().then((function(){return e._push()}));var t=this._nextOperationToPush;if(!t)return Promise.resolve();this._isPushing=!0;var n=function(){var n=e._queuedOperations.indexOf(t);return-1!==n&&e._queuedOperations.splice(n,1),e._ensureBookmarks(),e._isPushing=!1,e._save().then((function(){return e._push()}))},i=function(t){e._isPushing=!1,e._collection._reportSyncError(t)};return"create"===t.operation?this._syncManager.createBookmarks({bookmarks:[t.data]}).then((function(){return e._bookmarkData.push(t.data),n()}),i):"remove"===t.operation?this._syncManager.removeBookmark(t.id).then((function(){var i=e._bookmarkData.findIndex((function(e){return e.id===t.id}));if(-1!==i){var o=e._bookmarkData[i];if(e._bookmarkData.splice(i,1),t.removeCollaboration&&o.urn)return e._syncManager.removeCollaborators("urn/".concat(o.urn),[e._syncManager._userId]).finally(n)}return n()}),i):(this._services.log("Unknown bookmark operation ".concat(t.operation)),n())}},{key:"sync",value:function(){var e=this;return this._lock.execute((function(){return e._sync()}))}},{key:"getBookmarks",value:function(){return this._bookmarks}},{key:"findBookmark",value:function(e){return this.getBookmarks().find((function(t){return t.isReferenceTo(e)}))}},{key:"createBookmark",value:function(e,t,n,i){var o=this,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){},s=function(e){var t=o._bookmarks.find((function(t){return t.id===e}));a(null,t)};if(this._config.SHARED_LOCAL_STORAGE)this._storageInterface.createBookmark(this._collection,e,t,n,i,(function(e,n){!e&&n?(o._deserialize(n),s(t)):a(e)}));else{var c=this._bookmarks.find((function(e){return e.id===t}));c?a(null,c):(this._services.log("Creating bookmark: "+e+" data: "+JSON.stringify(n)),this._pushOperation({operation:"create",condition:i,data:r({id:t,type:e},n)}),this._saveAndPushChanges(),s(t))}}},{key:"removeBookmark",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};this._config.SHARED_LOCAL_STORAGE?this._storageInterface.removeBookmark(this._collection,e,n,i):(this._services.log("Removing bookmark: ".concat(JSON.stringify(e.toJSON()))),this._bookmarks.find((function(t){var n=t.id;return e.id===n}))&&(this._pushOperation({operation:"remove",removeCollaboration:n,condition:t,id:e.id}),this._saveAndPushChanges()),i(null))}},{key:"_nextOperationToPush",get:function(){var e=[];return this._queuedOperations.find((function(t){if(!(t.condition||t.id&&e.includes(t.id)))return t;"create"===t.operation&&t.data&&e.push(t.data.id)}))}}]),t}(f);e.exports=y},function(e,t,n){var i=n(0),o=n(8),r=n(45),a=n(15),s=n(5),c=n(2);function l(e,t,n){this._readOnly=n,this._owner=t,this._setData(e),this._localStorage=void 0}function u(e,t,n,o,r,a,s,l){var u=t._owner._core,h=e._owner._core,p=n&&e.id===t.id,d=h._getSourceHrefOfComponent(e),_=u.getComponentWithId(t.id),f=!(_&&_.etag||"unmodified"!==e.state),m=!p&&!d,v=m;if(r&&!_&&(d||m)&&e.id===t.id&&(t._data.id=c.generateUuid(),t.state="modified",t.etag=void 0,t.version=void 0,t.md5=void 0,t.length=void 0),a&&a._copyComponentMapping(e.id,l,t.id,s)&&(v=!1,p||(t.state="modified")),m){if(f){if(d=h._getHrefOfComponent(e),u._setSourceHrefOfComponent(d,t,s),!d&&v)throw new i(i.INVALID_STATE,"Failed to determine the source href of a component that does not have a local file.")}else if(v)throw new i(i.INVALID_STATE,"Could not use server-to-server copy for component "+e.id)}else u._setSourceHrefOfComponent(d,t,s);d&&(t.state="modified")}Object.defineProperties(l.prototype,{rootNode:{get:function(){return this.getChildWithAbsolutePath(r.ROOT_PATH)},set:function(){throw new i(i.READ_ONLY,'Property "rootNode" is read-only.')}},hasLocalStorage:{get:function(){return this._localStorage},set:function(){throw new i(i.READ_ONLY,"Cannot set the property hasLocalStorage.")}},isDirty:{get:function(){return this._isDirty},set:function(){throw new i(i.READ_ONLY,"Cannot set the property isDirty.")}},changeCount:{get:function(){return this._data.local&&this._data.local.change||0},set:function(){throw new i(i.READ_ONLY,"Cannot set the property changeCount.")}}}),l.prototype.getChildWithId=function(e){return this._allNodes[e]},l.prototype.getChildWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof r?t:void 0},l.prototype.getChildrenOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new i(i.INVALID_PARAMS,"Unknown node");var t,n=[],o=e._data.children;if(Array.isArray(o))for(t=0;t<o.length;t++){var r=o[t],a=this._allNodes[r.id];if(!a)throw new i(i.INVALID_DATA,"Node not in cache");n[n.length]=a}return n},l.prototype.addChild=function(e,t,n,o){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(t=t||c.generateUuid(),this._allNodes[t])throw new i(i.DUPLICATE_VALUE,"Node already exists in branch.");if(n&&("number"!=typeof n||n%1!=0))throw new i(i.INVALID_PARAMS,'Param "index" must be an integer.');var a=o?this._allNodes[o.id]:this.rootNode;if(!a)throw new i(i.INVALID_PARAMS,"Unknown parent node.");var s=new r;s.id=t,e&&(s.name=e),s._parentPath=a.absolutePath||a._parentPath;var l=a._data.children;return l?(n>=0&&n<=l.length||(n=l.length),n===l.length?l[n]=s._data:l.splice(n,0,s._data)):a._data.children=[s._data],this._allNodes[s.id]=s,s._owner=this._owner,this._setDirty(),s},l.prototype.removeChild=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new i(i.INVALID_PARAMS,"Cannot remove the root node.");var t=e.id;if(!t)throw new i(i.INVALID_PARAMS,'Param "node" must have an id.');var n=this._nodeDataOfParentOfNode(e);if(!n)throw new i(i.INVALID_PARAMS,"Node not found in this branch.");return n.parentNodeData.children.splice(n.index,1),0===n.parentNodeData.children.length&&delete n.parentNodeData.children,e=this._allNodes[t],this._removeNodeFromCachesRecursively(e._data),this._setDirty(),e},l.prototype.moveChild=function(e,t,n){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new i(i.INVALID_PARAMS,"Cannot move the root node.");if(t&&("number"!=typeof t||t%1!=0))throw new i(i.INVALID_PARAMS,'Param "index" must be an integer.');var o=e.id;if(!o)throw new i(i.INVALID_PARAMS,'Param "node" must have an id.');var r=this._nodeDataOfParentOfNode(e);if(e=this._allNodes[o],!r)throw new i(i.INVALID_PARAMS,"Node not found in this branch.");var a=n?this._allNodes[n.id]:this.rootNode;if(!a)throw new i(i.INVALID_PARAMS,"Unknown parent node.");if(this._nodeIdIsDescendantOf(a.id,e._data))throw new i(i.INVALID_PARAMS,"Must not create a cycle.");var s=r.parentNodeData.children.splice(r.index,1)[0];try{var c=a._data.children;c?(t>=0&&t<=c.length||(t=c.length),t===c.length?c[t]=s:c.splice(t,0,s)):a._data.children=[s]}catch(e){throw r.parentNodeData.children.splice(r.index,0,s),e}return 0===r.parentNodeData.children.length&&delete r.parentNodeData.children,this._setDirty(),this._allNodes[o]},l.prototype.copyChild=function(e,t,n,i,o,r){return this._copyChild(e,t,n,i,o,!1,r)},l.prototype.replaceChild=function(e,t,n,i){return this._copyChild(e,void 0,void 0,t,n||e.id,!0,i)},l.prototype.allComponents=function(){var e,t=[];for(e in this._allComponents)this._allComponents.hasOwnProperty(e)&&t.push(this._allComponents[e]);return t},l.prototype.getComponentWithId=function(e){return this._allComponents[e]},l.prototype.getComponentWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof a?t:void 0},l.prototype.getComponentsOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new i(i.INVALID_PARAMS,"Unknown node");var t,n=[],o=e._data.components;if(Array.isArray(o))for(t=0;t<o.length;t++){var r=o[t],a=this._allComponents[r.id];if(!a)throw new i(i.INVALID_DATA,"Component not in cache");n[n.length]=a}return n},l.prototype.addComponent=function(e,t,n,o,r,s,l,u,h,p){var d=this._localStorage;if(!d)throw new i(i.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadNewComponent() followed by addComponentWithUploadResults()");if("function"!=typeof p&&r)throw new i(i.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(h&&"string"!=typeof h)throw new i(i.INVALID_PARAMS,'Param "id" must be of type string.');if(!r&&!l)throw new i(i.INVALID_PARAMS,"Must provide either source or sourceHref.");try{if(l){var _=this._getBranchOf(this).compositeHref;if(_){var f=c.endPointOf(_),m=c.endPointOf(l);if(f&&m&&f!==m)throw new i(i.WRONG_ENDPOINT,"Given source href has an invalid endpoint: "+m)}}var v=this._local();h=h||c.generateUuid();var y=new a;y.id=h,y.name=e,y.type=t,y.relationship=n,y.path=o,y.state="modified";var g=this,E=function(e){if(!e)try{if(h&&g._allComponents[h])throw new i(i.DUPLICATE_VALUE,'The "id" of a component must be unique.');var t=u?g._allNodes[u.id]:g.rootNode;if(!t)throw new i(i.INVALID_PARAMS,"Unknown parent node.");var n=g._normalizedAbsolutePathForItem(y,t);if(g._absolutePaths[n])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+n);if(!c.isValidAbsolutePath(n))throw new i(i.INVALID_PARAMS,"Invalid absolute path: "+n);y._parentPath=t.absolutePath||t._parentPath;var o=t._data.components;o?o.push(y._data):t._data.components=[y._data],y._owner=g._owner,l&&g._setSourceHrefOfComponent(l,y),g._allComponents[y.id]=y,g._absolutePaths[n]=y,g._setDirty()}catch(t){d.removeComponentAsset(y,v),l&&g._setSourceHrefOfComponent(void 0,y),y=void 0,e=t}if(p)return p(e,y);if(e)throw e;return y};if(!r)return E();d.ingestComponentAsset(y,r,s,v,E)}catch(e){if(p)return p(e);throw e}},l.prototype.addComponentWithUploadResults=function(e,t,n,o,r){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(r.compositeId!==this._owner.compositeId)throw new i(i.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var s=Object.keys(r.records);if(1!==s.length)throw new i(i.INVALID_PARAMS,"Param uploadResults must contain records of exactly one component upload.");if(this._localStorage)throw new i(i.INVALID_PARAMS,"This method is for in-browser use only. Use addComponent() instead.");var c=r.records[s[0]],l=c.id;if(this._allComponents[l])throw new i(i.DUPLICATE_VALUE,"Duplicate component id: "+l);var u=o?this._allNodes[o.id]:this.rootNode;if(!u)throw new i(i.INVALID_PARAMS,"Unknown parent node.");var h=new a;h.id=l,h.name=e,h.type=c.type,h.relationship=t,h.path=n,h.state="unmodified",h.etag=c.etag,h.length=c.length,h.version=c.version,h.md5=c.md5;var p=this._normalizedAbsolutePathForItem(h,u);if(this._absolutePaths[p])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+p);h._parentPath=u.absolutePath||u._parentPath;var d=u._data.components;return d?d.push(h._data):u._data.components=[h._data],h._owner=this._owner,this._allComponents[l]=h,this._absolutePaths[p]=h,this._setDirty(),h},l.prototype.updateComponent=function(e,t,n,o){var r=this._localStorage;if(!r)throw new i(i.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadComponent() to upload a new component asset and then call updateComponentWithUploadResults()");if("function"!=typeof o)throw new i(i.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new i(i.INVALID_PARAMS,"Unknown component.");try{var a=this;r.ingestComponentAsset(e,t,n,this._local(),(function(t){if(!t)try{"modified"!==e.state?e.state="modified":a._setDirty(),a._setSourceHrefOfComponent(void 0,e)}catch(n){t=n,e=void 0}o(t,e)}))}catch(e){o(e)}},l.prototype.updateComponentWithUploadResults=function(e,t){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new i(i.INVALID_PARAMS,"Unknown component.");if(this._localStorage)throw new i(i.INVALID_PARAMS,"This method is for in-browser use only. Use updateComponent() instead.");if(t.compositeId!==this._owner.compositeId)throw new i(i.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var n=t.records[e.id];if(!n)throw new i(i.INVALID_PARAMS,"Param uploadResults does not contain an upload record for the given component.");return e.etag=n.etag,e.version=n.version,e.md5=n.md5,e.length=n.length,e},l.prototype.removeComponent=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');var t=e.id;if(!t)throw new i(i.INVALID_PARAMS,'Param "component" must have an id.');var n=this._nodeDataOfParentOfComponent(e);if(!n)throw new i(i.INVALID_PARAMS,"Component not found in this branch.");return n.parentNodeData.components.splice(n.index,1),0===n.parentNodeData.components.length&&delete n.parentNodeData.components,e=this._allComponents[t],delete this._allComponents[t],delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._localStorage&&(this._localStorage.removeComponentAsset(e,this._local()),this._setSourceHrefOfComponent(void 0,e)),e._owner=void 0,e._parentPath="",this._setDirty(),e},l.prototype.moveComponent=function(e,t){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');var n=e.id;if(!n)throw new i(i.INVALID_PARAMS,'Param "component" must have an id.');var o=this._nodeDataOfParentOfComponent(e);if(!o)throw new i(i.INVALID_PARAMS,"Component not found in this branch.");var r=t?this._allNodes[t.id]:this.rootNode;if(!r)throw new i(i.INVALID_PARAMS,"Unknown parent node.");var a=this._normalizedAbsolutePathForItem(e,r);if(this._absolutePaths[a])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+a);var s=o.parentNodeData.components.splice(o.index,1)[0],c=r._data.components;return c?c.push(s):r._data.components=[s],0===o.parentNodeData.components.length&&delete o.parentNodeData.components,e=this._allComponents[n],delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],e._parentPath=r.absolutePath||r._parentPath,this._absolutePaths[a]=e,this._setDirty(),e},l.prototype.copyComponent=function(e,t,n,i,o){return this._copyComponent(e,t,n,i,!1,o)},l.prototype.replaceComponent=function(e,t,n,i){return this._copyComponent(e,void 0,t,n||e.id,!0,i)},l.prototype.assetOfComponent=function(e,t){try{if(!this._localStorage)throw new i(i.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');if(!e.id)throw new i(i.INVALID_PARAMS,'Param "component" must have an id.');var n=this._localStorage.componentAssetPath(e,this._local());if(!t)return n;s.exists(n,(function(e){t(void 0,e?n:null)}))}catch(e){if(!t)throw e;t(e)}},l.prototype._getHrefOfComponent=function(e){var t,n=this._getBranchOf(e);if(n.compositeLinks)return c.getUrlFromLinks(n.compositeLinks,o.COMPONENT,{component_id:e.id});var i=n.compositeHref;return i&&void 0!==e.version&&(t=c.appendPathElements(i,e.id),t+=";version="+e.version),t},l.prototype._setSourceHrefOfComponent=function(e,t,n){var i=t.id,o=this._componentSourceHrefLookup(!0,n);e?o[i]=e:o[i]&&delete o[i]},l.prototype._getSourceHrefOfComponent=function(e,t){var n=e.id,i=this._componentSourceHrefLookup(!1,t);if(i)return i[n]},l.prototype._copySourceHrefsFrom=function(e){var t=e._componentSourceHrefLookup(!1),n=this.allComponents(),i=n.length;if(i&&t){var o,r=this._componentSourceHrefLookup(!0);for(o=0;o<i;o++){var a=n[o].id;r[a]=t[a]}}},l.prototype._getBranchOf=function(e){return e._owner?this._getBranchOf(e._owner):e},l.prototype._isSameComposite=function(e){var t=this._getBranchOf(this),n=this._getBranchOf(e);return t._data.id===n._data.id&&t.compositeHref===n.compositeHref&&this._localStorage===e._localStorage},l.prototype._stringify=function(e,t){if(e){var n=this._data.local,i=null;try{delete this._data.local,i=JSON.stringify(this._data,void 0,t?2:void 0)}catch(e){throw e}finally{n&&(this._data.local=n)}return i}return JSON.stringify(this._data,void 0,t?2:void 0)},l.prototype._setData=function(e){var t=new r(e,this._readOnly,!0);t._owner=this._owner,t._parentPath="";var n={},o={},s={};o[t.id]=t,s[r.ROOT_PATH]=t;var l=this;return function e(t,n,o,s,u){var h,p,d,_=t.components;if(Array.isArray(_))for(h=0;h<_.length;h++){var f=_[h],m=new a(f,l._readOnly);if(n[m.id])throw new i(i.INVALID_DATA,"Duplicate component id: "+m.id);if(m._owner=l._owner,m._parentPath=u,s[d=l._normalizedAbsolutePathForItem(m)])throw new i(i.INVALID_DATA,"Duplicate absolute path: "+d);if(!c.isValidAbsolutePath(d))throw new i(i.INVALID_DATA,"Invalid absolute component path: "+d);n[m.id]=m,s[d]=m}var v=t.children;if(Array.isArray(v))for(h=0;h<v.length;h++){var y=v[h],g=new r(y,l._readOnly);if(o[g.id])throw new i(i.INVALID_DATA,"Duplicate node id: "+g.id);if(p=g.path,g._owner=l._owner,g._parentPath=u,p){if(s[d=l._normalizedAbsolutePathForItem(g)])throw new i(i.INVALID_DATA,"Duplicate absolute path: "+d);if(!c.isValidAbsolutePath(d))throw new i(i.INVALID_DATA,"Invalid node absolute path: "+d);s[d]=g}o[g.id]=g,e(y,n,o,s,g.path?c.appendPathElements(u,g.path):u)}}(e,n,o,s,r.ROOT_PATH),this._data=e,this._allComponents=n,this._allNodes=o,this._absolutePaths=s,this._isDirty=!1,this},l.prototype._removeNodeFromCachesRecursively=function(e){var t,n=e.components;if(Array.isArray(n))for(t=0;t<n.length;t++){var i=n[t].id,o=this._allComponents[i];delete this._allComponents[i],delete this._absolutePaths[this._normalizedAbsolutePathForItem(o)],o._owner=void 0,this._localStorage&&(this._localStorage.removeComponentAsset(o,this._local()),this._setSourceHrefOfComponent(void 0,o))}var r=e.children;if(Array.isArray(r))for(t=0;t<r.length;t++)this._removeNodeFromCachesRecursively(r[t]);var a=e.id,s=this._allNodes[a];delete this._allNodes[a],s.path&&delete this._absolutePaths[this._normalizedAbsolutePathForItem(s)],s._owner=void 0},l.prototype._local=function(){return this._data.local||(this._data.local={version:2}),this._data.local},l.prototype._componentSourceHrefLookup=function(e,t){if(e&&this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(t||(t=e?this._local():this._data.local)){var n=t["componentS2SCopy#srcHref"];return!n&&e&&(n=t["componentS2SCopy#srcHref"]={}),n}},l.prototype._recursiveReset=function(e,t){var n,i=e.components;if(i)for(n=i.length-1;n>=0;n--){var o=i[n];"committedDelete"===o.state?(delete i[n],delete this._allComponents[o.id],delete o._owner,this._localStorage&&this._localStorage.removeComponentAsset(o,this._local()),this._setSourceHrefOfComponent(void 0,o,this._local())):(delete o.etag,delete o.version,delete o.length,delete o.md5,o.state="modified",t&&t(o))}var r=e.children;if(r)for(n=0;n<r.length;n++)this._recursiveReset(r[n],t)},l.prototype._nodeIdIsDescendantOf=function(e,t){var n,i=t.children;if(i)for(n=0;n<i.length;n++){var o=i[n];if(o.id===e||this._nodeIdIsDescendantOf(e,o))return!0}return!1},l.prototype._recursivelyGetAllComponentsOfChild=function(e,t){t=t||[];var n,i,o=e._data||e,r=o.components;if(r)for(i=r.length,n=0;n<i;n++)t[t.length]=this._allComponents[r[n].id];var a=o.children;if(a)for(i=a.length,n=0;n<i;n++)t=this._recursivelyGetAllComponentsOfChild(a[n],t);return t},l.prototype._nodeDataOfParentOfNode=function(e,t){t=t||this._data;var n,i=e._data.id,o=t.children;if(o)for(n=0;n<o.length;n++){var r=o[n];if(r.id===i)return{parentNodeData:t,index:n};var a=this._nodeDataOfParentOfNode(e,r);if(a)return a}return null},l.prototype._nodeDataOfParentOfComponent=function(e,t){t=t||this._data;var n,i=e._data.id,o=t.components;if(o)for(n=0;n<o.length;n++)if(o[n].id===i)return{parentNodeData:t,index:n};var r=t.children;if(r)for(n=0;n<r.length;n++){var a=r[n],s=this._nodeDataOfParentOfComponent(e,a);if(s)return s}return null},l.prototype._determineAbsolutePathChangesRecursively=function(e,t,n){var i,o=e.components;if(o)for(i=0;i<o.length;i++){var r=o[i],a=this._allComponents[r.id];n.push({item:a,parentPath:t,absPath:c.appendPathElements(t,r.path)})}var s=e.children;if(s)for(i=0;i<s.length;i++){var l=s[i],u=this._allNodes[l.id],h=l.path,p=h?c.appendPathElements(t,h):t;n.push({item:u,parentPath:t,absPath:h?p:void 0}),this._determineAbsolutePathChangesRecursively(l,p,n)}},l.prototype._setPathOfNode=function(e,t){var n=t?c.appendPathElements(e.parentPath,t):e.parentPath,o=[{item:e,absPath:t?n:void 0}];this._determineAbsolutePathChangesRecursively(e._data,n,o);for(var r=0;r<o.length;r++){var a=o[r],s=o[r].item;if(a.absPath){var l=a.absPath.toLowerCase(),u=this._absolutePaths[l];if(u){if(s.absolutePath&&u===this._normalizedAbsolutePathForItem(s))return;throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+l)}if(!c.isValidAbsolutePath(l))throw new i(i.INVALID_PARAMS,"Invalid absolute path: "+l)}}for(var h=0;h<o.length;h++){var p=o[h],d=p.item;if(d._data.path&&delete this._absolutePaths[this._normalizedAbsolutePathForItem(d)],p.absPath){var _=p.absPath.toLowerCase();this._absolutePaths[_]=p.item}p.parentPath&&(d._parentPath=p.parentPath)}e._data.path=t},l.prototype._setPathOfComponent=function(e,t){if(!this._allComponents[e.id])throw new i(i.INVALID_PARAMS,"Unknown component.");var n=c.appendPathElements(e.parentPath,t).toLowerCase();if(this._absolutePaths[n])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path for component: "+n);if(!c.isValidAbsolutePath(n))throw new i(i.INVALID_PARAMS,"Invalid absolute path: "+n);delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._absolutePaths[n]=e,e._data.path=t},l.prototype._setDirty=function(e){e||"pendingDiscard"!==this._data.state&&"pendingDelete"!==this._data.state&&"committedDelete"!==this._data.state||console.error("Modifying deleted composite"),this._isDirty=!0,this._local().change=this.changeCount+1,e||"unmodified"!==this._data.state&&this._data.state||(this._data.state="modified")},l.prototype._normalizedAbsolutePathForItem=function(e,t){return(t?c.appendPathElements(t.absolutePath||t._parentPath,e.path):e.absolutePath).toLowerCase()},l.prototype._hasSameEndpoint=function(e){var t=this._getBranchOf(this).compositeHref,n=this._getBranchOf(e).compositeHref;if(t&&n){var i=c.endPointOf(t),o=c.endPointOf(n);if(i&&o&&i!==o)return!1}return!0},l.prototype._copyComponent=function(e,t,n,o,r,a){if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');if(a&&"function"!=typeof a)throw new i(i.INVALID_PARAMS,"Param callback must be a function.");var s=this,c=e._owner._core,l=this._isSameComposite(c),h=l||this._hasSameEndpoint(e),p=c._local(),d=this._localStorage,_=c._localStorage,f=d&&_;if(f&&!a&&!l)throw new i(i.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!f&&!h)throw new i(i.NO_LOCAL_STORAGE,"Cannot copy between two different endpoints without local storage.");var m=function(e,t,n){u(e,t,l,0,!o,f?d:void 0,n,p)},v=f?_.componentAssetPath(e,p):void 0;if(!a)return this._copyComponentModel(e,t,r,n,o,m);if(l||!v)try{a(void 0,this._copyComponentModel(e,t,r,n,o,m))}catch(e){a(e)}else{var y={};d.ingestComponentAsset(e,v,!0,y,(function(i){if(i)a(i);else try{p=y,a(void 0,s._copyComponentModel(e,t,r,n,o,m))}catch(e){a(e)}}))}},l.prototype._copyComponentModel=function(e,t,n,o,r,s){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');var l=e._owner,u=new a(JSON.parse(JSON.stringify(e._data)));o?(u.path=o,u.id=r||c.generateUuid()):r&&(u.id=r),u._owner=this._owner,e.id===u.id&&this._isSameComposite(l._core)||(u.state="modified",u.etag=void 0,u.version=void 0,u.md5=void 0,u.length=void 0);var h,p,d=this._allComponents[u.id];if(d&&!n)throw new i(i.DUPLICATE_VALUE,"Component already exists.");if(n&&!d)throw new i(i.INVALID_PARAMS,"Could not find existing component.");if(n){var _=this._nodeDataOfParentOfComponent(d);if(!_)throw new i(i.INVALID_PARAMS,"Parent node of existing component not found in this branch.");var f=_.parentNodeData.id;if(!(p=this._allNodes[f]))throw new i(i.INVALID_STATE,"Unknown parent node.");h=_.index}else if(!(p=t?this._allNodes[t.id]:this.rootNode))throw new i(i.INVALID_PARAMS,"Unknown parent node.");u._parentPath=p.absolutePath||p._parentPath;var m=this._normalizedAbsolutePathForItem(u),v=this._absolutePaths[m];if(v&&v!==d)throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+m);if(!c.isValidAbsolutePath(m))throw new i(i.INVALID_PARAMS,"Component path must be a valid path for a component.");var y=this._local();s&&s(e,u,y=c.deepCopy(y));var g=p._data.components;return n?g[h]=u._data:g?g.push(u._data):p._data.components=[u._data],this._data.local=y,this._allComponents[u.id]=u,this._absolutePaths[m]=u,this._setDirty(),u},l.prototype._copyChild=function(e,t,n,o,r,a,s){if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "node".');var c=this,l=e._owner._core,h=this._isSameComposite(l),p=h||this._hasSameEndpoint(e),d=l._local(),_=this._localStorage,f=l._localStorage,m=_&&f,v=l._recursivelyGetAllComponentsOfChild(e);if(v.length>0){if(m&&!s&&!h)throw new i(i.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!m&&!p)throw new i(i.NO_LOCAL_STORAGE,"Cannot copy components between two different endpoints without local storage.")}var y=function(e,t,n){u(e,t,h,0,!0,m?_:void 0,n,d)};if(!s)return this._copyChildModel(e,t,n,a,o,r,y);var g=function(){s(void 0,c._copyChildModel(e,t,n,a,o,r,y))};if(0===v.length||h||!m)try{g()}catch(e){s(e)}else{var E,O,A={},S=v.length,b=0,L=function(e){if(e&&!O&&(O=e),0==--b)if(O)s(O);else try{d=A,g()}catch(e){s(e)}};for(E=0;E<S;E++){var T=v[E],I=f.componentAssetPath(T,d);I&&(b++,_.ingestComponentAsset(T,I,!0,A,L))}if(0===b)try{g()}catch(e){s(e)}}},l.prototype._copyChildModel=function(e,t,n,o,s,l,u){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");var h=e._owner,p=new r(JSON.parse(JSON.stringify(e._data)));s?(p.path=s,p.id=l||c.generateUuid()):l&&(p.id=l),p._owner=this._owner,e.isRoot&&(delete p._data.local,delete p._data["manifest-format-version"]);var d,_=this._allNodes[p.id];if(_&&!o)throw new i(i.DUPLICATE_VALUE,"Child node already exists.");if(o&&!_)throw new i(i.INVALID_PARAMS,"Could not find existing node to replace.");if(o){var f=this._nodeDataOfParentOfNode(_);if(!f)throw new i(i.INVALID_PARAMS,"Parent of existing node not found in this branch.");var m=f.parentNodeData.id;if(!(d=this._allNodes[m]))throw new i(i.INVALID_STATE,"Unknown parent node.");n=f.index}else if(!(d=t?this._allNodes[t.id]:this.rootNode))throw new i(i.INVALID_PARAMS,"Unknown parent node.");if(p._parentPath=d.absolutePath||d._parentPath,p.path){var v=this._normalizedAbsolutePathForItem(p),y=this._absolutePaths[v];if(y&&y!==_)throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+v);if(!c.isValidAbsolutePath(v))throw new i(i.INVALID_PARAMS,"Node path must be a valid path for a node.")}var g=c.flatCopy(this._allNodes),E=c.flatCopy(this._allComponents),O=c.flatCopy(this._absolutePaths),A=c.deepCopy(this._local());if(_&&function e(t,n,i,o,r,a){var s,c;delete i[t.id],t.path&&delete r[n._normalizedAbsolutePathForItem(t)];var l=t._data.children;if(l)for(c=l.length,s=0;s<c;s++)e(i[l[s].id],n,i,o,r,a);var u=t._data.components;if(u)for(c=u.length,s=0;s<c;s++){var h=o[u[s].id];delete o[h.id],delete r[n._normalizedAbsolutePathForItem(h)],n._localStorage&&(n._localStorage.removeComponentAsset(h,a),n._setSourceHrefOfComponent(void 0,h,a))}}(_,this,g,E,O,A),function e(t,n,o,s,l,h,p,d){if(s[t.id])throw new i(i.DUPLICATE_VALUE,"Duplicate node id: "+t.id);var _;if(s[t.id]=t,t.path){if(h[_=n._core._normalizedAbsolutePathForItem(t)])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+_);h[_]=t}var f,m,v=t._data.children;if(v)for(m=v.length,f=0;f<m;f++){var y=new r(v[f]);s[y.id]&&(y.id=c.generateUuid()),y._owner=n,y._parentPath=t.absolutePath||t._parentPath,e(y,n,o,s,l,h,p,d)}var g=t._data.components;if(g)for(m=g.length,f=0;f<m;f++){var E=new a(g[f]),O=E.id;if(l[O]&&(E.id=c.generateUuid(),E.state="modified",E.etag=void 0,E.version=void 0,E.md5=void 0,E.length=void 0),E._owner=n,E._parentPath=t.absolutePath||t._parentPath,u&&u(o.getComponentWithId(O),E,p),l[E.id])throw new i(i.DUPLICATE_VALUE,"Duplicate component id: "+E.id);if(l[E.id]=E,h[_=n._core._normalizedAbsolutePathForItem(E)])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+_);h[_]=E}}(p,this._owner,h,g,E,O,A,h._local()),o)d._data.children[n]=p._data;else{var S=d._data.children;S?(n>=0&&n<=S.length||(n=S.length),n===S.length?S[n]=p._data:S.splice(n,0,p._data)):d._data.children=[p._data]}return this._allNodes=g,this._allComponents=E,this._absolutePaths=O,this._data.local=A,this._setDirty(),p},l.prototype._verifyIntegrity=function(e,t,n){var o,a=this,s=[],l=!1,u=function(e){return s.push(new i(i.INVALID_STATE,e)),t&&(l||(t("Branch for composite "+a.rootNode.id+" has the following errors:"),l=!0),t("   "+e)),!1},h=function(e,t){return!!e||u(t)},p=[],d=function(e){(p.indexOf(e)<0||u("Item "+e.id+" encountered more than once"))&&p.push(e)},_=c.flatCopy(this._allComponents),f=c.flatCopy(this._allNodes),m=c.flatCopy(this._absolutePaths),v=Object.keys(m),y=v.length;for(o=0;o<y;o++){var g=v[o];h("/"===g.charAt(0),"Absolute path "+g+" does not start with a slash.")}var E=m[r.ROOT_PATH];h(E,"Cannot find root node via path")&&(h(E.id===this._data.id,"Root node has correct id"),h(E.path===r.ROOT_PATH,"Root node has correct path"),h(""===E._parentPath,"Root node has correct parent path"),h(E._owner===this._owner,"Root node has correct owner"),h(E._data===this._data,"Root node has correct data"),h(f[E.id]===E,"Cannot find root node via id")&&delete f[E.id],delete m[r.ROOT_PATH]),function e(t,n){var i,o,r=t.children;if(r)for(i=0;i<r.length;i++){var s=r[i],l=f[s.id];(l||u("Node "+s.id+" is not in cache."))&&(d(l),h(l._data===s,"Node "+l.id+" _data property incorrect."),delete f[l.id],l.path&&l._owner&&(o=a._normalizedAbsolutePathForItem(l),(m[o]||u("Absolute path of node "+l.id+" ("+o+") is not in cache."))&&delete m[o]),h(l._parentPath===n,"Parent path of node "+l.id+" should be "+n+" but is "+l._parentPath),h(l._owner===a._owner,"Node "+l.id+" _owner property is not correct.")),e(s,s.path?c.appendPathElements(n,s.path):n)}var p=t.components;if(p)for(i=0;i<p.length;i++){var v=p[i],y=_[v.id];(y||u("Component "+v.id+" is not in cache."))&&(d(y),h(y._data===v,"Component "+y.id+" _data property incorrect."),delete _[y.id],y._owner&&(o=a._normalizedAbsolutePathForItem(y),(m[o]||u("Absolute path "+o+" is not in cache."))&&delete m[o]),h(y._parentPath===n,"Parent path of component "+y.id+" should be "+n+" but is "+y._parentPath),h(y._owner===a._owner,"Component "+y.id+" _owner property is not correct."))}}(this._data,r.ROOT_PATH);var O=Object.keys(_);for(o=0;o<O.length;o++)u("Component "+O[o]+" is in cache but could not be found.");for(O=Object.keys(f),o=0;o<O.length;o++)u("Node "+O[o]+" is in cache but could not be found.");for(O=Object.keys(m),o=0;o<O.length;o++)u("Absolute path "+O[o]+" is in cache but could not be found.");if(this._localStorage){var A=this._localStorage.componentIds(this._local());for(o=0;o<A.length;o++)h(this._allComponents[A[o]],"Component "+A[o]+" is in local storage mapping but could not be found in the manifest.");if(e)for(A=Object.keys(this._allComponents),o=0;o<A.length;o++){var S=A[o],b=this._allComponents[S],L=this._localStorage.componentAssetPath(b,this._local());h(L,"Component "+S+" does not have an entry in local storage mapping.")&&n&&h(n.existsSync(L),"Asset "+L+" does not exist.")}var T=this._componentSourceHrefLookup();if(T)for(y=(A=Object.keys(T)).length,o=0;o<y;o++){var I=this._allComponents[A[o]];I?h("modified"===I.state,"Component "+A[o]+" is in local source href mapping but has a state of "+I.state):h(!1,"Component "+A[o]+" is in local source href mapping but could not be found in the manifest.")}}return s.length?s:null},e.exports=l},function(e,t,n){var i,o;function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}void 0===(o="function"==typeof(i=function(){var e={"+":!0,"#":!0,".":!0,"/":!0,";":!0,"?":!0,"&":!0},t={"*":!0};function n(e){return encodeURI(e).replace(/%25[0-9][0-9]/g,(function(e){return"%"+e.substring(3)}))}function i(e){return e=e.replace(/%../g,""),encodeURIComponent(e)===e}function o(o){var a="";e[o.charAt(0)]&&(a=o.charAt(0),o=o.substring(1));var s="",c="",l=!0,u=!1,h=!1;"+"==a?l=!1:"."==a?(c=".",s="."):"/"==a?(c="/",s="/"):"#"==a?(c="#",l=!1):";"==a?(c=";",s=";",u=!0,h=!0):"?"==a?(c="?",s="&",u=!0):"&"==a&&(c="&",s="&",u=!0);for(var p=[],d=o.split(","),_=[],f={},m=0;m<d.length;m++){var v=d[m],y=null;if(-1!=v.indexOf(":")){var g=v.split(":");v=g[0],y=parseInt(g[1])}for(var E={};t[v.charAt(v.length-1)];)E[v.charAt(v.length-1)]=!0,v=v.substring(0,v.length-1);var O={truncate:y,name:v,suffices:E};_.push(O),f[v]=O,p.push(v)}return{varNames:p,prefix:c,substitution:function(e){for(var t="",i=0,o=0;o<_.length;o++){var a=_[o],p=e(a.name);if(null==p||Array.isArray(p)&&0==p.length||"object"==r(p)&&0==Object.keys(p).length)i++;else if(t+=o==i?c:s||",",Array.isArray(p)){u&&(t+=a.name+"=");for(var d=0;d<p.length;d++)d>0&&(t+=a.suffices["*"]&&s||",",a.suffices["*"]&&u&&(t+=a.name+"=")),t+=l?encodeURIComponent(p[d]).replace(/!/g,"%21"):n(p[d])}else if("object"==r(p)){u&&!a.suffices["*"]&&(t+=a.name+"=");var f=!0;for(var m in p)f||(t+=a.suffices["*"]&&s||","),f=!1,t+=l?encodeURIComponent(m).replace(/!/g,"%21"):n(m),t+=a.suffices["*"]?"=":",",t+=l?encodeURIComponent(p[m]).replace(/!/g,"%21"):n(p[m])}else u&&(t+=a.name,h&&""==p||(t+="=")),null!=a.truncate&&(p=p.substring(0,a.truncate)),t+=l?encodeURIComponent(p).replace(/!/g,"%21"):n(p)}return t},unSubstitution:function(e,t,n){if(c&&(e=e.substring(c.length)),1==_.length&&_[0].suffices["*"]){for(var o=(S=_[0]).name,r=S.suffices["*"]?e.split(s||","):[e],a=l&&-1!=e.indexOf("="),h=1;h<r.length;h++)e=r[h],a&&-1==e.indexOf("=")&&(r[h-1]+=(s||",")+e,r.splice(h,1),h--);for(h=0;h<r.length;h++)e=r[h],l&&-1!=e.indexOf("=")&&(a=!0),1==(y=e.split(",")).length?r[h]=y[0]:r[h]=y;if(u||a){for(var p=t[o]||{},d=0;d<r.length;d++){var m=e;if(!u||m){if("string"==typeof r[d]){var v=(e=r[d]).split("=",1)[0];if(e=e.substring(v.length+1),l){if(n&&!i(e))return;e=decodeURIComponent(e)}m=e}else{if(v=(e=r[d][0]).split("=",1)[0],e=e.substring(v.length+1),l){if(n&&!i(e))return;e=decodeURIComponent(e)}r[d][0]=e,m=r[d]}if(l){if(n&&!i(v))return;v=decodeURIComponent(v)}void 0!==p[v]?Array.isArray(p[v])?p[v].push(m):p[v]=[p[v],m]:p[v]=m}}1==Object.keys(p).length&&void 0!==p[o]?t[o]=p[o]:t[o]=p}else{if(l)for(d=0;d<r.length;d++){var y=r[d];if(Array.isArray(y))for(var g=0;g<y.length;g++){if(n&&!i(y[g]))return;y[g]=decodeURIComponent(y[g])}else{if(n&&!i(y))return;r[d]=decodeURIComponent(y)}}void 0!==t[o]?Array.isArray(t[o])?t[o]=t[o].concat(r):t[o]=[t[o]].concat(r):1!=r.length||S.suffices["*"]?t[o]=r:t[o]=r[0]}}else{r=1==_.length?[e]:e.split(s||",");var E={};for(h=0;h<r.length;h++){for(var O=0;O<_.length-1&&O<h&&!_[O].suffices["*"];O++);if(O!=h){for(var A=_.length-1;A>0&&_.length-A<r.length-h&&!_[A].suffices["*"];A--);_.length-A!=r.length-h?E[h]=O:E[h]=A}else E[h]=h}for(h=0;h<r.length;h++)if((e=r[h])||!u){if(y=e.split(","),a=!1,u){o=(e=y[0]).split("=",1)[0],e=e.substring(o.length+1),y[0]=e;var S=f[o]||_[0]}else o=(S=_[E[h]]).name;for(d=0;d<y.length;d++)if(l){if(n&&!i(y[d]))return;y[d]=decodeURIComponent(y[d])}(u||S.suffices["*"])&&void 0!==t[o]?Array.isArray(t[o])?t[o]=t[o].concat(y):t[o]=[t[o]].concat(y):1!=y.length||S.suffices["*"]?t[o]=y:t[o]=y[0]}}return 1}}}function a(e){if(!(this instanceof a))return new a(e);for(var t=e.split("{"),n=[t.shift()],i=[],r=[],s=[],c=[];t.length>0;){var l=t.shift(),u=l.split("}")[0],h=l.substring(u.length+1),p=o(u);r.push(p.substitution),s.push(p.unSubstitution),i.push(p.prefix),n.push(h),c=c.concat(p.varNames)}this.fill=function(e){if(e&&"function"!=typeof e){var t=e;e=function(e){return t[e]}}for(var i=n[0],o=0;o<r.length;o++)i+=(0,r[o])(e),i+=n[o+1];return i},this.fromUri=function(e,t){t=t||{};for(var o={},r=0;r<n.length;r++){var a=n[r];if(e.substring(0,a.length)!==a)return;if(e=e.substring(a.length),r>=n.length-1){if(""==e)break;return}var c=i[r];if(!c||e.substring(0,c.length)===c){for(var l=n[r+1],u=r;;){if(u==n.length-2){var h=e.substring(e.length-l.length);if(h!==l)return;var p=e.substring(0,e.length-l.length);e=h}else if(l){var d=e.indexOf(l);p=e.substring(0,d),e=e.substring(d)}else if(i[u+1])-1===(d=e.indexOf(i[u+1]))&&(d=e.length),p=e.substring(0,d),e=e.substring(d);else{if(n.length>u+2){u++,l=n[u+1];continue}p=e,e=""}break}if(!s[r](p,o,t.strict))return}}return o},this.varNames=c,this.template=e}return a.prototype={toString:function(){return this.template},fillFromObject:function(e){return this.fill(e)},test:function(e,t){return!!this.fromUri(e,t)}},a})?i.apply(t,[]):i)||(e.exports=o)},function(e,t,n){var i=n(46),o=n(48);e.exports=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||i)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var s=0;s<16;++s)t[r+s]=a[s];return t||o(a)}},function(e,t,n){var i=n(0),o=n(5);function r(e,t,n){n?this._setData(n,e.href):this._data={"push-journal-format-version":3,"composite-href":e.href,"uploaded-components":{}},this._filePath=t,this._waitingCallbacks=[],this._commitInProgress=!1,this._needAnotherCommit=!1}r.readJournal=function(e,t,n,i){o.readFile(e,"utf8",(function(o,a){var s;if(o&&o.code&&n&&(o=void 0),!o)try{a=JSON.parse(a),s=new r(t,e,a)}catch(i){n?s=new r(t,e):o=i}i(o,o?void 0:s)}))},Object.defineProperties(r.prototype,{compositeHref:{get:function(){return this._data["composite-href"]},set:function(e){e?this._data["composite-href"]=e:delete this._data["composite-href"]}},manifestEtag:{get:function(){return this._data.etag},set:function(e){e?this._data.etag=e:delete this._data.etag}},currentBranchEtag:{get:function(){return this._data["current-branch-etag"]},set:function(e){e?this._data["current-branch-etag"]=e:delete this._data["current-branch-etag"]}},compositeAssetId:{get:function(){return this._data["composite-asset-id"]},set:function(e){e?this._data["composite-asset-id"]=e:delete this._data["composite-asset-id"]}},compositeRepoMetadata:{get:function(){return this._data["composite-repo-metadata"]},set:function(e){e?this._data["composite-repo-metadata"]=e:delete this._data["composite-repo-metadata"]}},compositeLinks:{get:function(){return this._data["composite-links"]},set:function(e){e?this._data["composite-links"]=e:delete this._data["composite-links"]}},changeCount:{get:function(){return this._data.change},set:function(e){e?this._data.change=e:delete this._data.change}},compositeHasBeenCreated:{get:function(){return!!this._data["composite-created"]},set:function(e){e?this._data["composite-created"]=!0:delete this._data["composite-created"]}},compositeHasBeenDeleted:{get:function(){return!!this._data["composite-deleted"]},set:function(e){e?this._data["composite-deleted"]=!0:delete this._data["composite-deleted"]}},isEmpty:{get:function(){return 0===Object.keys(this._data["uploaded-components"]).length&&!this.compositeHasBeenDeleted&&!this.manifestEtag},set:function(){throw new i(i.READ_ONLY,"This property is read-only.")}},isComplete:{get:function(){return!!(this._data.etag&&this._data.change||this._data["composite-deleted"])},set:function(){throw new i(i.READ_ONLY,"This property is read-only.")}}}),r.prototype.recordUploadedComponent=function(e,t,n,i,o,r,a){var s={etag:t,length:o,version:n,md5:i};r&&(s["storage-name"]=r),a&&(s["source-href"]=a),s.timestamp=(new Date).toISOString(),this._data["uploaded-components"][e]=s},r.prototype.idsOfAllUploadedComponents=function(){return Object.keys(this._data["uploaded-components"])},r.prototype.getRecordForUploadedComponent=function(e){var t=this._data["uploaded-components"][e];if(t&&!this.isComplete){var n=t.timestamp;if(!n)return this.removeRecordForUploadedComponent(e);if(n=new Date(n),isNaN(n.getTime()))return this.removeRecordForUploadedComponent(e);if(Date.now()-n.getTime()>=6048e5)return this.removeRecordForUploadedComponent(e)}return t},r.prototype.removeRecordForUploadedComponent=function(e){delete this._data["uploaded-components"][e]},r.prototype.applyToBranch=function(e,t){var n=this;if(!this.isComplete)throw new i(i.INVALID_STATE,"Journal is not complete.");var o=e.isDirty;if(this.compositeHasBeenDeleted)e._data.state="committedDelete",e.manifestEtag=this.manifestEtag;else{var r,a="unmodified"!==e.compositeState&&this.changeCount!==e.changeCount,s=this.idsOfAllUploadedComponents(),c=s.length;for(r=0;r<c;r++){var l=s[r],u=e.getComponentWithId(l);if(u){var h=this.getRecordForUploadedComponent(u.id);u._data.etag=h.etag,u._data.length=h.length,u._data.version=h.version,u._data.md5=h.md5,h["source-href"]?e._core._getSourceHrefOfComponent(u)===h["source-href"]&&(u._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,u)):e.hasLocalStorage&&e._localStorage.componentAssetName(u,e._local())===h["storage-name"]?(u._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,u)):e.hasLocalStorage||(u._data.state="unmodified")}}e.manifestEtag=this.manifestEtag,["compositeHref","compositeAssetId","compositeLinks","compositeRepoMetadata"].forEach((function(t){n[t]!==e[t]&&(e[t]=n[t])})),a||(e._data.state="unmodified")}t&&(e._isDirty=o)},r.prototype.commitChanges=function(e){if(this._filePath){var t=this;t._commitInProgress?(this._needAnotherCommit=!0,e&&this._waitingCallbacks.push(e)):function e(n){t._needAnotherCommit=!1,t._commitInProgress=!0,t._waitingCallbacks=[],o.writeFileAtomically(t._filePath,JSON.stringify(t._data),"utf8",(function(i){var o,r=n.length;for(o=0;o<r;o++)try{n[o](i)}catch(e){}t._needAnotherCommit?e(t._waitingCallbacks):t._commitInProgress=!1}))}(e?[e]:[])}else e&&e()},r.prototype._setData=function(e,t){if(e["push-journal-format-version"]<=2){var n=e["uploaded-components"];if(n){var i,o=Object.keys(n),r=o.length;for(i=0;i<r;i++){var a=n[o[i]];"number"==typeof a.version&&(a.version=String(a.version))}}e["push-journal-format-version"]=3}var s=this._verify(e,t);if(null===s)return this._data=e,this;throw s},r.prototype._verify=function(e,t){return 3!==e["push-journal-format-version"]?new i(i.INVALID_DATA,"Wrong push journal format version."):e["composite-href"]!==t?new i(i.INVALID_DATA,"Composite and journal hrefs mismatch."):e["uploaded-components"]?null:new i(i.INVALID_DATA,"Missing component list.")},e.exports=r},function(e,t){e.exports=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(25),u=n(0),h=u.networkError,p=u.unexpectedResponse,d=n(5),_=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments))}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"uploadAssetAtComponentHref",value:function(e,t,n,i,o,r,a,s){var c=this,l={};t&&(l["Content-Type"]=t);var d=function(t,n){t?delete l["If-Match"]:l["If-Match"]="*";var i=c._service.invoke("PUT",e,l,a,void 0,(function(e,t){if(e)return n(h("Error uploading component",e,t));var i=t.statusCode;if(200===i||201===i||204===i){var o,r=t.responseText||t.response;if(!r||0===r.length)return n(void 0,t);try{o=JSON.parse(r)}catch(i){return(e=new u(u.INVALID_DATA,"Invalid JSON returned by server",i)).response=t,n(e,t,o)}n(void 0,t,o)}else 507===i?((e=new u(u.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,n(e)):((e=p("Unexpected response uploading component",e)).response=t,n(e))}));return i.token=r,i};return d(i,(function(t,n,o){if(t){if(!(n=t.response))return s(t);var r=n.statusCode;i||404!==r?!i||409!==r&&412!==r?s(t):c._checkForComponentAlreadyUploaded(e,a,(function(e,t){e?s(null,e,{md5:t}):d(!1,s)})):d(!0,s)}else s(void 0,n,o)}))}},{key:"updateManifestAtHref",value:function(e,t,n,i,o){var r={"Content-Type":"application/vnd.adobe.dcx-manifest+json"};return i?r["If-Match"]="*":n&&(r["If-Match"]=n),this._service.invoke("PUT",e,r,t,void 0,(function(e,t){if(e)return o(h("Error updating manifest",e,t));var r=t.statusCode;!t.headers.etag||200!==r&&201!==r&&204!==r?412===r||n&&!i&&409===r?((e=new u(u.UPDATE_CONFLICT,"Manifest has been changed")).response=t,o(e)):o(p("Unexpected response updating manifest",e,t)):o(void 0,t)}))}},{key:"_checkForComponentAlreadyUploaded",value:function(e,t,n){var i=this;if(!(d.canUseFileSystem&&e&&t&&t.filename))return n();d.getMD5Hash(t.filename,(function(t,o){if(t)return n();i.headRequest(e,(function(e,t){if(e)return n();var i=t&&t.statusCode,r=t&&t.headers["content-md5"];200!==i||r!==o?n():n(t,r)}))}))}}])&&r(n.prototype,i),t}(l);e.exports=_},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(0),r=o.networkError,a=o.unexpectedResponse,s=n(2),c=s.merge,l=s.appendPathElements,u=function(){function e(t,n,i){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._service=t,this._server=n,this._allowedEndpointRegex=i,n&&(this._endPoint=s.endPointOf(n)),this.SYNC_ASYNC_DEFAULT_DELAY=5,this.ASYNC_DEFAULT_DELAY=1,this.DEFAULT_POLL_DELAY=10,this._maxRedirects=5,this._authenticationAllowedList=[],!this._endPoint)throw new o(o.INVALID_PARAMS,"Could not determine endpoint from: "+n);this.authenticationAllowedList=["adobe.com","adobe.io","fotolia.net"]}var t,n;return t=e,(n=[{key:"isValidHref",value:function(e){var t=s.endPointOf(e);return!t||this._isEndpointAllowed(t)}},{key:"isDomainOnAllowedList",value:function(e){var t=s.parseURI(e).authority;if(!t||0===t.length)return!0;for(var n=t.length,i=this._authenticationAllowedList.length,o=0;o<i;o++){var r=this._authenticationAllowedList[o],a=r.length;if((n>a?t.slice(-a):t)===r)return!0}return!1}},{key:"getAsset",value:function(e,t,n,i){if(!(e=this._resolveUrl(e)))return i(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+e));var l,u={};"string"==typeof t?u["If-None-Match"]=t:c(u,t);var h,p=this,d=0;function _(e,t){if(e)return i(r("Error downloading an asset",e,t));var n=t.statusCode;if(200===n)i(void 0,t);else if(304===n)i(void 0,t);else if(301===n||302===n||303===n||307===n)if(!p._service.handlesRedirects&&p.maxRedirects)if(d<p.maxRedirects){var o=t.headers.location;o?h(o):i(a("Missing location header in redirect response",e,t))}else i(a("Too many redirects",e,t));else i(a("Unexpected response getting an asset",e,t));else i(a("Unexpected response getting an asset",e,t))}return(l=(h=function(t){var i={responseType:n};return t&&(d++,i.reuseRequestDesc=l,p.isDomainOnAllowedList(t)||(u.Authorization=null)),p._service.invoke("GET",t||e,u,void 0,i,_)})()).progress=s.noOp,l}},{key:"getAssetAsType",value:function(e,t,n,i){return this.getAsset(e,n,t,(function(e,t){if(e)return i(e);if(200===t.statusCode){var n=t.response||t.responseText;i(void 0,n,t.headers.etag,t)}else 304===t.statusCode?i(void 0,null,t.headers.etag,t):i(a("Unexpected response getting asset",e,t))}))}},{key:"headRequest",value:function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,(function(e,n){if(e)return t(e);t(e,n)}))}},{key:"abortAll",value:function(){this._service.abortAll()}},{key:"_resolveUrl",value:function(e){if(void 0!==e){var t=s.endPointOf(e);if(t){if(!this._isEndpointAllowed(t))return;return e}return l(this._server,e)}}},{key:"_isEndpointAllowed",value:function(e){return this._allowedEndpointRegex&&this._allowedEndpointRegex.test(e)||e===this._endPoint}},{key:"_makeRelativeUrl",value:function(e){var t=s.endPointOf(e);if(t){if(t!==this._endPoint)return;var n=s.parseURI(e);(n.scheme||n.authority)&&(e=n.path,n.query&&(e+="?"+n.query),n.fragment&&(e+="#"+n.fragment))}return e}},{key:"_parseAsyncResponse",value:function(e){var t=e.responseText||e.response;if(!t)throw new o(o.INVALID_DATA,"No body data.");var n={},i=t.indexOf("\n");if(-1===i)throw new o(o.INVALID_DATA,"Could not find status line.");var r=t.slice(0,13===t.charCodeAt(i-1)?i-1:i).split(" ");if(n.statusCode=parseInt(r[1],10),!n.statusCode)throw new o(o.INVALID_DATA,"Could not find status code.");r.length>2&&(n.statusText=r[2]);var a=t.search(/\r?\n\r?\n/);-1===a&&(a=t.length);var c=t.slice(i+1,a);n.headers=s.parseHeaders(c);var l="\r"===t.charAt(a)?a+4:a+2;return n.response=t.slice(l),n}},{key:"_pollForAsyncResponse",value:function(e,t,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this._parseAsyncResponse,c=arguments.length>4?arguments[4]:void 0,l=Date.now()+1e3*t,u={responseType:"text",reuseRequestDesc:n,noSoonerThen:l};s.log("asynchronous request - polling"),n=this._service.invoke("GET",e,void 0,void 0,u,(function(t,l){if(t)return c(r("Error polling for an asynchronous reponse",t,l));var u=l.statusCode;if(202===u){s.log("asynchronous request - not yet ready");var h=l.headers["retry-after"];h&&(h=parseInt(h,10)),i._pollForAsyncResponse(e,h||i.DEFAULT_POLL_DELAY,n,o,c)}else if(200===u){s.log("asynchronous request - success");try{l=o(l)}catch(e){return c(a("Error parsing response body.",e,l))}200===(u=l.statusCode)||201===u||204===u?c(void 0,l):c(a("Unexpected response polling for an asynchronous response",t,l))}else s.log("asynchronous request - error"),c(a("Unexpected response polling for an asynchronous response",t,l))}))}},{key:"_handle202Response",value:function(e,t,n,i,o){var r,s=e.responseText||e.response;try{r=JSON.parse(s)}catch(t){return o(a("Error parsing 202 response body.",t,e))}var c=r.href;if(!c)return o(a("202 response missing an href.",void 0,e));var l=e.headers["retry-after"];l=l?parseInt(l,10):n,this._pollForAsyncResponse(this._resolveUrl(c),l,t,i,o)}},{key:"_doHeadRequest",value:function(e){var t=this;return new Promise((function(n,i){t.headRequest(e,(function(e,t){return e?i(new o(o.NETWORK_ERROR,"HEAD request failed",e)):[200,202,204].includes(t.statusCode)?void n(t):i(o.wrapError(o.UNEXPECTED_RESPONSE,"HEAD request yielded unexpected response",void 0,t))}))}))}},{key:"_getCopyDelegate",value:function(e,t,n){var i=this;if(!this.isValidHref(e))return n(new o(o.WRONG_ENDPOINT,"Source href is not compatible with this service: ".concat(e)));n(null,(function(n,o,r,a,s,c){return i.copyAssetToComponentId(n,o,t,r,a,s,e,c)}))}},{key:"maxRedirects",get:function(){return this._maxRedirects},set:function(e){if("number"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a number.");this._maxRedirects=Math.floor(e)}},{key:"authenticationAllowedList",get:function(){return this._authenticationAllowedList},set:function(e){if(!Array.isArray(e))throw new o(o.INVALID_PARAMS,"Expecting an array.");this._authenticationAllowedList=e}}])&&i(t.prototype,n),e}();e.exports=u},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function c(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function l(e,t,n){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var p=n(24),d=n(0),_=n(8),f=n(2),m=n(14),v=n(58),y=d.networkError,g=d.unexpectedResponse,E=n(59),O=n(20),A=/^(https:\/\/cc-api-storage(?:-stage)?\.adobe\.io(?::443)?\/.+)\/([^;/]+)/,S=/\/[^/]+$/,b=/[\\/:*?"|><]/g,L=/^CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]$/i,T=function(e){function t(e,n,i,o){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(r=c(this,u(t).call(this,e,n,i))).setRootDocument(o),r}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(t,e),n=t,(i=[{key:"getRootDocument",value:function(e){var t=this;this._getAllPages(this._server).then((function(n){var i=n.result,o=n.etag,r=n.headers;t.setRootDocument(i),e(null,i,o,r)}),e)}},{key:"setRootDocument",value:function(e){this._rootDocument=e,this._rootLinks=e&&e._links}},{key:"getAssets",value:function(e){var t;try{t=this._getUrlFromRootDocument("Assets.json",_.PAGE)}catch(t){return e(t)}this._getAllPages(t).then((function(t){var n=t.result,i=t.etag,o=t.headers;return e(null,n,i,o)}),e)}},{key:"getRepositories",value:function(e){var t;try{t=this._getUrlFromRootDocument("Repositories.json")}catch(t){return e(t)}this._getAllPages(t).then((function(t){var n=t.result,i=t.etag,o=t.headers;return e(null,n,i,o)}),e)}},{key:"getEffectiveACFromLinks",value:function(e,t){var n=function(e){t(new d(d.UNEXPECTED_RESPONSE,"Unable to get permissions for object",e))},i=f.getUrlFromLinks(e,_.AC_EFFECTIVE);this._getResponse(i).then((function(e){var i=e&&e.result,o=i&&i[_.PRIMARY]||i["*"];if(!o)return n();t(null,o)}),n)}},{key:"getRepoMetadataFromLinks",value:function(e,t){var n=f.getUrlFromLinks(e,_.METADATA);this._getResponse(n).then((function(e){return t(null,e.result)}),t)}},{key:"getLinksFromUrn",value:function(e,t){var n=this;this._getRootLinks().then((function(i){var o=f.getUrlFromLinks(i,_.RESOLVE_ID,{id:e});n.getLinksFromUrl(o,t)}),t)}},{key:"getLinksFromPath",value:function(e,t,n){var i=this;this._getRootLinks().then((function(o){var r=f.getUrlFromLinks(o,_.RESOLVE_PATH,{repositoryId:e,path:t});i.getLinksFromUrl(r,n)}),n)}},{key:"getLinksFromUrl",value:function(e,t){this._getLinks(e).then((function(e){var n=e.links,i=e.response;return t(null,n,i)}),t)}},{key:"getCollection",value:function(e,t,n){var i={};t&&(i["If-None-Match"]=t),this._getAllPages(e,i).then((function(e){var t=e.result,i=e.etag,o=e.headers;return n(null,t,i,o)}),n)}},{key:"getComponent",value:function(e,t,n){var i=this.getComponentHref(e,e.version);return this.getAsset(i,void 0,t,n)}},{key:"getRenditionOfComponent",value:function(e,t,n,i,o){var r;try{r=this.getComponentRenditionHref(e,e.version,n)}catch(e){return o(e)}this.getAsset(r,{accept:t},i,o)}},{key:"getCompositeManifest",value:function(e,t,n){var i=this.getCompositeManifestHref(e);return this.getAssetAsType(i,"text",t,n)}},{key:"createCompositeDirectory",value:function(e,t,n){var i=this;if(t)return n(new d(d.INVALID_PARAMS));this._createComposite(e).then((function(t){var o=t.response,r=i._getLinksFromResponse(o),a=JSON.parse(o.response),s=a["repo:createdBy"],c=a["storage:assignee"];(c&&"org"===c.type?i._setDenyFromLinks(r,s):Promise.resolve()).then((function(){e.links=r,e.href=f.getUrlFromLinks(r,_.PRIMARY),e.assetId=o.headers["x-resource-id"],e.repoMetadata=a,e.storageAssignee=c,e.isWritable=!0,e.isParentWritable=!0,n(void 0,o)}),n)}),n)}},{key:"deleteCompositeDirectory",value:function(e,t){t(new d(d.INVALID_STATE,"Composites can only be discarded on platform."))}},{key:"discardComposite",value:function(e,t){var n=this,i=a({},"If-Match","*");this._service.invoke("POST",f.getUrlFromLinks(e.links,_.DISCARD),i,void 0,{responseType:"text"},(function(i,o){var r=function(){t(y("Error disposing composite directory",i,o))};return i||![200,201,204,403,404].includes(o.statusCode)?r():403===o.statusCode?n._getLinks(f.getUrlFromLinks(e.links,_.PRIMARY)).then((function(e){var n=e.links;if(f.getUrlFromLinks(n,_.DISCARD))return r();t(void 0,o)}),r):void t(void 0,o)}))}},{key:"renameCompositeIfNecessary",value:function(e,t){var n=this;if(!e.isRenamePending||this._doesRepoNameMatchPath(e))return t();this.getRepoMetadataFromLinks(e.links,(function(i,o){if(i)return t(i);if(!o["storage:assignee"]||"org"!==o["storage:assignee"].type)return t();var r=o["repo:path"],a=r.replace(S,""),s=o["repo:repositoryId"];if(a===r||!s)return t(new d(d.UNEXPECTED_RESPONSE,"Could not get metadata: ".concat(e.id)));n._findAvailablePath(e,a,s).then((function(i){var r=i.path,a=i.name;n._invokeOperation("move",{href:e.href,"if-match":"*"},{path:r,"repo:repositoryId":s,"if-match":"*"},(function(n){if(n)return n.response&&[403,404].includes(n.response.statusCode)?t(new d(d.ACCESS_DENIED,"User does not have permission to move this asset.",n)):t(n);o["repo:name"]=a,o["repo:path"]=r,e.repoMetadata=o,e.isRenamePending=!1,t()}))}),t)}))}},{key:"uploadComponent",value:function(e,t,n,i,o,r){if(!e._owner||!e._owner.compositeLinks)throw new d(d.INVALID_STATE,"Component must be part of a branch of a bound composite.");var a=e._owner.compositeLinks,s=a[_.CREATE]&&a[_.CREATE]["repo:maxsingletransfersize"]||9437184;if(o instanceof m&&o.size>=s)return this._blockUploadComponent(e,t,n,i,o,r);var c=f.getUrlFromLinks(e._owner.compositeLinks,_.COMPONENT,{component_id:e.id});return this.uploadAssetAtComponentHref(c,e.type,e._owner.compositeHref,t,n,i,o,r)}},{key:"_blockUploadComponent",value:function(e,t,n,i,o,r){var a=this,s=new v,c=f.getUrlFromLinks(e._owner.compositeLinks,_.BLOCK_INITIALIZE),l=JSON.stringify({component_id:e.id,"repo:size":o.size,"repo:blocksize":6e6,"repo:reltype":_.COMPONENT,"repo:if-match":t?null:"*","dc:format":e.type});return this._postRequest(c,{"Content-Type":"application/vnd.adobecloud.bulk-transfer+json"},l,s).then((function(t){for(var n=a._processJsonResponse(t).result,i=n["repo:blocksize"],r=n._links[_.BLOCK_TRANSFER],c=f.getUrlFromLinks(n._links,_.BLOCK_FINALIZE),l=[],u=0,h=0;h<o.size;u++,h+=i){var p=r[u].href,d=Math.min(o.size,h+i)-1;l.push(a._uploadBlock(p,o.filename,e.type,h,d,s))}return Promise.all(l).then((function(){return a._postRequest(c,{"Content-Type":"application/vnd.adobecloud.bulk-transfer+json"},JSON.stringify(n),s)}))})).then((function(){return a._doHeadRequest(f.getUrlFromLinks(e._owner.compositeLinks,_.COMPONENT,{component_id:e.id,revision:e.version}))})).then((function(e){return r(null,e,{})}),r),s}},{key:"_uploadBlock",value:function(e,t,n,i,o,r){var a=this,s={Authorization:null,"X-Request-Id":null,"Content-Length":o-i+1,"Content-Type":n},c=new m(t,void 0,{start:i,end:o});return new Promise((function(t,n){var i={method:"PUT",href:e,headers:s,callback:function(i,o){i?n(i):[200,201,204].includes(o.statusCode)?t():n(g("Unexpected status code from: ".concat(e),void 0,o))},body:c,options:{responseType:"json"}};a._service._doRequest(i),r&&r.push(i,!0)}))}},{key:"copyAssetToComponentId",value:function(e,t,n,i,o,r,a,s){var c=this._invokeOperation("copy",{href:a,"if-match":"*"},{href:"".concat(n,"?component_id=").concat(e),"if-match":"*"},s);return c.token=r,c}},{key:"updateManifest",value:function(e,t,n,i){var o=f.getUrlFromLinks(e.compositeLinks,_.MANIFEST);return this.updateManifestAtHref(o,t,e.manifestEtag,n,i)}},{key:"updateManifestAtHref",value:function(e,t,n,i,o){var r={"Content-Type":"application/vnd.adobe.dcx-manifest+json"};return i?r["If-Match"]="*":n&&(r["If-Match"]=n),this._service.invoke("PUT",e,r,t,void 0,(function(e,t){if(e)return o(y("Error updating manifest",e,t));var r=t.statusCode;!t.headers.etag||200!==r&&201!==r&&204!==r?412===r||n&&!i&&409===r?((e=new d(d.UPDATE_CONFLICT,"Manifest has been changed")).response=t,o(e)):o(g("Unexpected response updating manifest",e,t)):o(void 0,t)}))}},{key:"getHrefForComposite",value:function(e){return e.href}},{key:"getCompositeManifestHref",value:function(e){return f.getUrlFromLinks(e.links,_.MANIFEST)}},{key:"getBranchManifestHref",value:function(e){return f.getUrlFromLinks(e.compositeLinks,_.MANIFEST)}},{key:"getComponentHref",value:function(e,t){var n=e._owner;if(!n||!n.compositeLinks)throw new d(d.INVALID_STATE,"Component must be part of a branch of a bound composite.");return f.getUrlFromLinks(n.compositeLinks,_.COMPONENT,{revision:t,component_id:e.id})}},{key:"getComponentRenditionHref",value:function(e,t,n){var i=e._owner;if(!i||!i.compositeLinks)throw new d(d.INVALID_STATE,"Component must be part of a branch of a bound composite.");return f.getUrlFromLinks(i.compositeLinks,_.RENDITION,{fragment:"id=".concat(e.id),size:n})}},{key:"_invokeOperation",value:function(e,t,n,i){var o=this,r=f.getUrlFromLinks(this._rootLinks,_.OPS),a={op:e,target:n,source:t};f.log("[invoke operation]: ".concat(JSON.stringify(a,void 0,2)));var s=function(e,t){var n;if(e)return(t=e.response)?void(507===t.statusCode?((e=new d(d.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,i(e)):i(e)):i(e);try{n=JSON.parse(t.responseText||t.response)}catch(n){return(e=new d(d.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,i(e)}if(n.error)return(e=new d(d.UNEXPECTED_RESPONSE,"Error in operation result: "+JSON.stringify(n.error,void 0,2))).response=t,i(e);i(void 0,t,n&&n.asset)},c=this._service.invoke("POST",r,{"Content-Type":"application/json"},JSON.stringify([a]),{responseType:"text"},(function(t,n){if(t)return s(y("Error invoking operation "+e,t,n));var i=n.statusCode;200===i||201===i||204===i?s(void 0,n):202===i?o._handle202Response(n,c,o.SYNC_ASYNC_DEFAULT_DELAY,(function(e){return e}),(function(e,t){s(e,t)})):s(g("Unexpected response for operation "+e,t,n),n)}));return c}},{key:"_getLinks",value:function(e){var t=this;return this._doHeadRequest(e).then((function(e){return{links:t._getLinksFromResponse(e),response:e}}))}},{key:"_getLinksFromResponse",value:function(e){var t=e&&e.headers.link;if(!t)throw new d(d.UNEXPECTED_RESPONSE,"HEAD request did not return link header");var n=E.parse(t);return n&&n.refs.reduce((function(e,t){var n=t.rel,i=t.uri,o=function(e,t){if(null==e)return{};var n,i,o=function(e,t){if(null==e)return{};var n,i,o={},r=Object.keys(e);for(i=0;i<r.length;i++)n=r[i],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)n=r[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(t,["rel","uri"]);return n&&(e[n]=e[n]||[],e[n].push(r({href:i},o))),e}),{})}},{key:"_getRootLinks",value:function(){var e=this;return new Promise((function(t,n){if(e._rootLinks)return t(e._rootLinks);e.getRootDocument((function(i){return i?n(i):t(e._rootLinks)}))}))}},{key:"_getAllPages",value:function(e,t){var n;return this._getPagedResponse(e,t).then((function e(t){if(t&&t.result&&t.result.children)return n?n.result.children=n.result.children.concat(t.result.children):n=t,t&&t.next?t.next().then(e):void 0})).then((function(){return n}))}},{key:"_getPagedResponse",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this._getResponse(e,n).then((function(e){var n,i=e.result,o=e.etag,a=e.headers;if(i&&i._page&&i._page.next&&i._links&&i._links[_.PAGE]){var s=new O(i._links[_.PAGE].href);n=function(){return t._getPagedResponse(s.fill(r({},i._page,{start:i._page.next,resource:_.PRIMARY})))}}return{result:i,etag:o,headers:a,next:n}}))}},{key:"_processJsonResponse",value:function(e){var t;try{var n=e.responseText||e.response;t=JSON.parse(n)}catch(t){var i=new d(d.INVALID_DATA,"Invalid JSON returned by server",t);throw i.response=e,i}return{result:t,etag:e.headers.etag,headers:e.headers,response:e}}},{key:"_getResponse",value:function(e,t){var n=this;return new Promise((function(i,o){n._service.invoke("GET",e,t,void 0,{responseType:"text"},(function(t,r){if(t)return o(y("Error reading from: ".concat(e),t,r));200===r.statusCode?i(n._processJsonResponse(r)):304===r.statusCode?i({etag:r.headers.etag,headers:r.headers}):o(g("Unexpected status code from: ".concat(e),void 0,r))}))}))}},{key:"_postRequest",value:function(e,t,n,i){var o=this;return new Promise((function(r,a){var s=function(t,n){return a(y("Error reading from: ".concat(e),t,n))},c=o._service.invoke("POST",e,t,n,{responseType:"text"},(function(t,n){if(t)return s(t,n);200===n.statusCode||201===n.statusCode||204===n.statusCode?r(n):202===n.statusCode?o._handle202Response(n,c,o.SYNC_ASYNC_DEFAULT_DELAY,void 0,(function(e,t){e?s(e,t):r(t)})):a(g("Unexpected status code from: ".concat(e),void 0,n))}));i&&i.push(c)}))}},{key:"_createComposite",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return new Promise((function(i,o){var r={"Content-Type":e.type},a=new O(e.href),s=t._getCompositeName(e,n),c=s.baseName,l=s.repoName,u=a.fill({path:l,respondWith:_.METADATA});t._service.invoke("POST",u,r,void 0,void 0,(function(r,a){return r||![200,201,204,409].includes(a.statusCode)?o(y("Error creating composite directory",r,a)):409===a.statusCode?i(t._createComposite(e,n+1)):(e.name=c,i({href:u,response:a}))}))}))}},{key:"_setDenyFromLinks",value:function(e,t){var n=this,i=f.getUrlFromLinks(e,_.AC_POLICY),o={"Content-Type":"application/vnd.adobecloud.accesscontrolpolicy+json"},r={"repo:acl":[{"repo:principal":{"xdm:provider":{"@id":"https://ims-na1.adobelogin.com/"},"@type":"https://ns.adobe.com/adobecloudplatform/ims/user","@id":t},"repo:modifier":"grant","repo:privileges":["read","write","delete"],"repo:relations":[_.DESCRIBED_BY,_.AC_POLICY,_.ANNOTATIONS,_.APP_METADATA,_.EMBEDDED_METADATA,_.METADATA,_.PRIMARY,_.RENDITION]},{"repo:principal":"all","repo:modifier":"deny","repo:privileges":["read","write","delete"]}]};return new Promise((function(e,t){n._service.invoke("PUT",i,o,JSON.stringify(r),{responseType:"text"},(function(n,i){return n?t(n):e(i)}))}))}},{key:"_findAvailablePath",value:function(e,t,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return new Promise((function(r,a){var s=i._getCompositeName(e,o).repoName,c="".concat(t,"/").concat(s),l=f.getUrlFromLinks(i._rootLinks,_.RESOLVE_PATH,{path:c,repositoryId:n});i.headRequest(l,(function(l,u){return l?a(l):404===u.statusCode?r({path:c,name:s}):200===u.statusCode||403===u.statusCode?r(i._findAvailablePath(e,t,n,o+1)):a(y("Unexpected status code",l))}))}))}},{key:"_getCompositeName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e.name;L.test(n)&&(n="".concat(n," "));var i="".concat(n).concat(t?" ".concat(t):"").replace(b,"_");return{baseName:i,repoName:"".concat(i).concat(f.getExtension(e.type))}}},{key:"_doesRepoNameMatchPath",value:function(e){var t=new RegExp("".concat(e.name,"( [0-9]+)?").concat(f.getExtension(e.type).replace(".","\\."))),n=e.repoMetadata&&e.repoMetadata["repo:name"];return t.test(n)}},{key:"_getStorageLinkTemplate",value:function(e){var t=this;this._storageLinkCache=this._storageLinkCache||{},this._storageLinkCache[e]=this._storageLinkCache[e]||{};var n=this._storageLinkCache[e];if(Date.now()<n.expiresAt){var i=new O(n.template);if(i)return Promise.resolve(i)}return n.fetchingPromise||(n.fetchingPromise=this._doHeadRequest(e).then((function(n){var i=n&&n.headers&&n.headers["x-resource-urn"];return i?new Promise((function(n,o){return t.getLinksFromUrn(i,(function(i,r){if(i)return o(i);try{var a=f.getTemplateFromLinks(r,_.COMPONENT);t._storageLinkCache[e]={template:a,expiresAt:Date.now()+36e5},n(new O(a))}catch(i){o(i)}}))})):Promise.reject(new d(d.INVALID_DATA,"Request for composite did not return a URN: ".concat(e)))})),n.fetchingPromise.catch((function(){return delete t._storageLinkCache[e].fetchingPromise}))),n.fetchingPromise}},{key:"_getCopyDelegate",value:function(e,n,i){var o=this;l(u(t.prototype),"_getCopyDelegate",this).call(this,e,n,(function(t,r){if(!t)return i(null,r);var a=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],i=!0,o=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){o=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(o)throw r}}return n}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}(A.exec(e)||[],3),s=a[1],c=a[2];if(!s||!c)return i(new d(d.INVALID_PARAMS,"Href is not for a component: ".concat(e)));o._getStorageLinkTemplate(s).then((function(e){var t=e.fill({component_id:c});i(null,(function(e,i,r,a,s,c){return o.copyAssetToComponentId(e,i,n,r,a,s,t,c)}))}),i)}))}},{key:"_handle202Response",value:function(e,t,n,i,o){var r=e&&e.headers&&e.headers.location;if(!r)return o(g("202 response missing an href.",void 0,e));this._pollForAsyncResponse(this._resolveUrl(r),n,t,i,o)}},{key:"_getUrlFromRootDocument",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_.PRIMARY;try{var n=this._rootDocument.children.find((function(t){return t["repo:name"]===e})),i=new O(n._links[t].href);return i.fill({})}catch(t){throw new d(d.INVALID_DATA,"".concat(e," does not exist in document root"),t)}}},{key:"_encodeURIComponent",value:function(e){return encodeURIComponent(e).replace(/!/g,"%21")}}])&&s(n.prototype,i),t}(p);e.exports=T},function(e,t,n){var i,o,r=n(12),a=n(15),s=n(13),c=n(0),l=n(22),u=n(2),h=n(5),p=n(14),d=a.STATES;function _(e,t,n){return c.wrapError(c.UNEXPECTED_RESPONSE,e,t,n)}function f(e,t,n){this._session=e,this._callback=t,this._cleanup=n,this._componentsPending=0,this.bytesTransfered=0,this.bytesTotal=0,this.onProgress=u.noOp;var i=this;this._reportProgress=function(e){if(e>0){i.bytesTransfered+=e;var t=i.onProgress;t&&t(i.bytesTransfered,i.bytesTotal)}}}f.prototype._callCallback=function(e,t){var n=this._callback;n&&(this._callback=void 0,n(e,t))},f.prototype._xferComplete=function(e,t){var n=this._cleanup;n?(this._cleanup=void 0,n(e,t)):this._callCallback(e,t)},f.prototype.abort=function(e){this._aborted||(this._aborted=!0,e||(this._callback=void 0,e=new Error("Aborted")),this._xferComplete(e),this._session._service.abortAllWithToken(this))};var m={};function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t["repo:etag"]||e.headers.etag,i=t["repo:version"]||e.headers["x-latest-version"]||e.headers.version||e.headers.revision,o=t.md5||e.headers["content-md5"],r=t["repo:size"]||t.size||parseInt(e.headers["content-length"]);return{etag:n,version:i,md5:o,length:r}}m.pullComposite=function(e,t,n){if(!e.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return this._pullComposite(e,t,"all",n)},m.pullMinimumComposite=function(e,t,n){if(!e.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return this._pullComposite(e,t,"min",n)},m.pullCompositeManifestOnly=function(e,t,n){return this._pullComposite(e,t,"none",n)},m.downloadComponents=function(e,t,n,i){var o=function e(t){return t._owner?e(t._owner):t}(t),r=new f(n,i);r._referenceBranch=o;var a=function(){return m._pullComponents(r,o,e||t.allComponents())};return o.hasLocalStorage?o._localStorage.loadPullJournal().then((function(e){r._journal=e,a()})):a(),r},m.pushComposite=function(e,t,n,i){var o,r=e._localStorage;(o=new f(n,i,(function(t,n){if(o._owner&&e.hasLocalStorage&&r.unregisterInMemoryBranchOrElement(o._owner),!e.hasLocalStorage){var i=o._journal;e._pushJournal=i.isEmpty?void 0:i}o._callCallback(t,n)})))._composite=e,o._overwriteExisting=t;var a=!e.isBound;if(o._compositeIsNew=a,e.hasLocalStorage)e._loadBranch(r.currentManifestPath(),!1,(function(t,n){if(t)return o._xferComplete(t);o._owner=n,e._localStorage.registerInMemoryBranchOrElement(n),l.readJournal(r.pushJournalPath(),e,!0,(function(t,n){if(t)return o._xferComplete(t);o._journal=n,m._pushComposite(e,o)}))}));else{if(!e.href)return o._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));o._owner=e.current.copy(),o._journal=e._pushJournal||new l(e),m._pushComposite(e,o)}return o},m.uploadNewComponent=function(e,t,n,o,a,s){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return i(o||u.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s)},m.uploadComponent=function(e,t,n,o,a){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.updateComponent() to update a component asset");return i(e.id,e.type,!1,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,t,n.id,n.href,o,a)},m.copyAssetForNewComponent=function(e,t,n,i,a,s){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return o(i||u.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s)},m.getURLForComponent=function(e,t){if(e._owner._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only.");return t.getComponentHref(e,e.version)},m._pullComposite=function(e,t,n,i){if("string"!=typeof e.href)throw new c(c.INVALID_STATE,"Composite must have an href");var o,r=function(i,r){if(i)return o._xferComplete(i);var a;r?(a=r.manifestEtag,o._referenceBranch=r):e.current&&(a=e.current.manifestEtag,o._referenceBranch=e.current);var l=t.getCompositeManifest(e,a,(function(t,i,a){if(t)return t.response&&404===t.response.statusCode?o._xferComplete(new c(c.NO_COMPOSITE,"Composite missing or deleted",t.underlyingError||t)):o._xferComplete(t);if(null===i&&!r)return o._xferComplete(void 0,null);var l;if(null!==i)try{if((l=(new s).parse(i))._localStorage=e._localStorage,l.compositeHref=e.href,l.compositeLinks=e.links,l.compositeRepoMetadata=e.repoMetadata,l.compositeAssetId=e.assetId,l.compositeIsWritable=e.isWritable,l.compositeParentAssetId=e.parentAssetId,l.compositeIsParentWritable=e.isParentWritable,l.compositeIsRenamePending=e.isRenamePending,l.compositeStorageAssignee=e.storageAssignee,l._collaborationType=e.collaborationType,l._clientDataString=e.clientDataString,l.manifestEtag=a,l.compositeState===d.committedDelete||l.compositeState===d.pendingDelete)return void o._session.deleteCompositeDirectory(e,(function(e){return e?o._xferComplete(new c(c.DELETED_COMPOSITE,"Error deleting composite directory",e)):o._xferComplete(new c(c.DELETED_COMPOSITE,"Composite is deleted"))}));o._referenceBranch&&l.hasLocalStorage&&l._updateLocalDataFromBranch(o._referenceBranch)}catch(e){return o._xferComplete(new c(c.INVALID_JSON,"Corrupted manifest",e))}else l=r;var u,h,p=l.allComponents();for(u=0;u<p.length;++u)(h=p[u]).state===d.pendingDelete||h.state===d.committedDelete?l.removeComponent(h):h.state=d.unmodified;p=void 0,"all"===n?p=l.allComponents():"min"===n&&(h=l.getComponentWithAbsolutePath("/META-INF/metadata.xml"))&&(p=[h]),p?m._pullComponents(o,l,p):o._xferComplete(void 0,l)}));l&&(l.token=o,l.progress=o._reportProgress)};return(o=new f(t,i,(function(t,n){if(t){var i=t.pulledBranch;i?(i.compositeState=d.unmodified,i.hasLocalStorage?h.writeFileAtomically(e._localStorage.pulledManifestPath(),t.pulledBranch.localData,"utf8",(function(){o._callCallback(t)})):o._callCallback(t)):o._callCallback(t)}else{if(null===n)return o._callCallback(void 0,null);if(n.compositeState=d.unmodified,n.readOnly=!0,n.hasLocalStorage){var r=e._localStorage.pulledManifestPath();h.writeFileAtomically(r,n.localData,"utf8",(function(e){if(e)return o._callCallback(e);n.manifestPath=r,n._isDirty=!1,o._callCallback(void 0,n)}))}else e._options.xhrBaseBranchSupport&&(e._pulledBranchData=n.localData),o._callCallback(void 0,n)}})))._composite=e,e.hasLocalStorage?e._localStorage.loadPullJournal().then((function(t){o._journal=t,e.loadPulledBranch(r)})):r(),o},m._pullComponents=function(e,t,n){if(!t.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage.");var i,o=e._session;function r(i,o){if(e._componentsPending-=1,i?(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:o,error:i})):e._journal&&e._journal.saveComponentPath(o),0===e._componentsPending&&!e._aborted){var r=e.failedComponents;if(r){i=new c(c.COMPONENT_DOWNLOAD_ERROR,"Failed to download all components");var a,s=r.length;for(a=0;a<s;a++){var l=r[a].error;if(l.code===c.OUT_OF_SPACE){i=new c(l.code,l.message);break}}i.pulledBranch=t,i.failedComponents=r}t.readOnly&&t.manifestPath&&(!r||n.length>r.length)?h.writeFileAtomically(t.manifestPath,t.localData,"utf8",(function(n){i=i||n,e._xferComplete(i,i?void 0:t)})):e._xferComplete(i,i?void 0:t)}}function a(t){if(!e._aborted){var n=e._journal;if(n&&n.restoreComponentPath(t))r(null,t);else{e.bytesTotal+=t.length||0;var i=t._owner._localStorage.tempPathForComponent(t),a=u.parentDirectory(i);h.ensureDirectoryExists(a,(function(n){if(n)return e.abort(n);var a=m._pullComponent(t,i,o,r);a.progress=e._reportProgress,a.token=e}))}}}function s(e){t.assetOfComponent(e,(function(t,n){"string"!=typeof n?a(e):r(void 0,e)}))}for(e._componentsPending=n.length,i=0;i<n.length;++i){var l,p=n[i];if(e._referenceBranch){var d=e._referenceBranch.getComponentWithId(p.id);d&&(l=d.etag)}p.etag!==l?a(p):s(p)}0===e._componentsPending&&e._xferComplete(void 0,t)},m._pullComponent=function(e,t,n,i){var o=e._owner;if(!e._owner.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return n.getComponent(e,new p(t),(function(n,r){if(n)i(n,e);else if(200===r.statusCode){var a=Number(r.headers["content-length"]);e.length&&!isNaN(a)&&a!==e.length?i(new c(c.UNEXPECTED_RESPONSE,"Incorrect content length",n,r)):o._localStorage.ingestComponentAsset(e,t,!1,o._local(),(function(t){i(t,e,r.headers.etag)}))}else 304===r.statusCode?i(void 0,e,r.headers.etag):i(_("Unexpected response getting a component",n,r),e)}))},m._pushComposite=function(e,t){var n=this;if(!e.href)return t._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));var i=t._owner,o=t._journal,a=t._compositeIsNew,s=t._overwriteExisting,l=t._session,u=i.changeCount,p=i.remoteData.length+50;if(t.bytesTotal=p,i.compositeState===d.committedDelete)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push a deleted composite"));if(!a&&i.compositeState===d.unmodified)return t._xferComplete();if(i.compositeState===d.pendingDiscard)return a&&!s?t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to delete unbound composite")):l.discardComposite(e,(function(e){t._xferComplete(e)}));if(i.compositeState===d.pendingDelete)return a&&!s?t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to delete unbound composite")):e.collaborationType===r.COLLABORATION.SHARED_WITH_USER?t._xferComplete(new c(c.INVALID_STATE,"Attempt to delete composite that is shared with this user.")):m._deleteComposite(t,s,(function(e,n){t._xferComplete(e,n)}));function f(n){if(a)return t._xferComplete(n);var i=l.getCompositeManifestHref(e);l.headRequest(i,(function(e,i){return e?t._xferComplete(e):404===i.statusCode?(n=new c(c.NO_COMPOSITE,"Composite does not exist; may have been deleted"),t._xferComplete(n)):t._xferComplete(n)}))}!function(e,t,n){if(e.isBound&&t.renameCompositeIfNecessary)return t.renameCompositeIfNecessary(e,n);n()}(e,l,(function(r){if(r)return t._xferComplete(r);!function(e,t,n,i,o){function r(e){e||(t.compositeHasBeenCreated=!0);var n,i=t._compositeCreationCallbacks,o=i.length;for(n=0;n<o;n++)try{i[n](e)}catch(e){}t._compositeCreationCallbacks=void 0}e.isBound||t.compositeHasBeenCreated?o():t._compositeCreationCallbacks?t._compositeCreationCallbacks.push(o):(t._compositeCreationCallbacks=[o],i.createCompositeDirectory(e,n,(function(t,o){if(t){if(t.code!==c.ALREADY_EXISTS)return r(_("Unexpected response creating a composite directory",t,o));if(n)r();else{var a=i.getCompositeManifestHref(e);i.headRequest(a,(function(e,t){return e?r(e):404!==t.statusCode?r(e=new c(c.ALREADY_EXISTS,"Composite already exists and overwriteExisting not specified")):void r()}))}}else r()})))}(e,o,s,l,(function(r){if(r)return t._xferComplete(r);n._applyCompositeChangesToBranchAndJournal(e,i,o,(function(n){if(n)return t._xferComplete(n);m._pushComponents(t,i,(function(){var r=t.failedComponents;if(r){n=new c(c.COMPONENT_UPLOAD_ERROR,"One or more components failed to upload.");var a,_=r.length;for(a=0;a<_;a++){var m=r[a].error;if(m.code===c.EXCEEDS_QUOTA){n=new c(m.code,m.message);break}}return n.failedComponents=r,f(n)}if(i.compositeState===d.modified){i.compositeState=d.unmodified,o.manifestEtag&&o.currentBranchEtag===i.manifestEtag&&(i.manifestEtag=o.manifestEtag);var v=i.remoteData;t.bytesTotal+=v.length,t.bytesTotal-=p;var y=l.updateManifest(i,v,s,(function(n,r){if(n)return f(n);var a=r.headers.etag;o.manifestEtag=a,o.currentBranchEtag=i.manifestEtag,o.changeCount=u,o.commitChanges((function(n){if(n)return t._xferComplete(n);o.applyToBranch(i),i.compositeState=d.unmodified,e.hasLocalStorage?h.writeFileAtomically(e._localStorage.pushedManifestPath(),i.localData,"utf8",(function(e){if(e)return t._xferComplete(e);i._isDirty=!1,t._xferComplete(null,i)})):(e._options.xhrBaseBranchSupport&&(e._pushedBranchData=i.localData),t._xferComplete(null,i))}))}));y&&(y.progress=t._reportProgress,y.token=t)}else t._xferComplete(null,i)}))}))}))}))},m._applyCompositeChangesToBranchAndJournal=function(e,t,n,i){e.links&&(t.compositeLinks=e.links,n.compositeLinks=e.links),e.assetId&&(t.compositeAssetId=e.assetId,n.compositeAssetId=e.assetId),e.repoMetadata&&(t.compositeRepoMetadata=e.repoMetadata,n.compositeRepoMetadata=e.repoMetadata),e.href!==t.compositeHref&&(t.compositeHref=e.href,n.compositeHref=e.href),n.commitChanges(i)},m._deleteComposite=function(e,t,n){var i=e._composite,o=e._owner,r=e._session;o.compositeState=d.committedDelete;var a=o.remoteData;e.bytesTotal=a.length,e._journal.manifestEtag&&e._journal.currentBranchEtag===o.manifestEtag&&(o.manifestEtag=e._journal.manifestEtag),r.updateManifest(o,a,t,(function(t){if(t)return n(t);r.deleteCompositeDirectory(i,(function(t){if(t)return n(t);e._journal.compositeHasBeenDeleted=!0,e._journal.commitChanges((function(e){if(e)return n(e);i.hasLocalStorage?h.writeFileAtomically(i._localStorage.pushedManifestPath(),o.localData,"utf8",(function(e){if(e)return n(e);n(void 0,o)})):n(void 0,o)}))}))}))},m._pushComponents=function(e,t,n){var i,o=t.allComponents(),a=e._composite,s=a._localStorage,l={},_=e._journal;function f(t,i,o){i?l[t.id]=i:delete l[t.id],o&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:t,error:o})),0===Object.keys(l).length&&_.commitChanges(n)}function m(t,n,i){f(t,"uploading"),h.info(n,(function(o,s){if(o)return o=new c(c.INVALID_STATE,"Component asset missing",o),void f(t,null,o);var l=s.size,h=u.filePathComponents(n).fileName,m=_.getRecordForUploadedComponent(t.id);if(m&&m.length===l&&m["storage-name"]===h)return t.etag=m.etag,t.version=m.version,t.md5=m.md5,t.length=m.length,t.state=d.unmodified,void f(t,null);e.bytesTotal+=l;var y=e._session.uploadComponent(t,i,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,new p(n,l),(function(e,n,i){if(!e){var o=v(n,i),r=o.etag,a=o.version,s=o.md5;r||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),a||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),s||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),e||(t.etag=r,t.version=a,t.md5=s,t.length=l,t.state=d.unmodified,_.recordUploadedComponent(t.id,r,a,s,l,h),_.commitChanges())}f(t,null,e)}));y&&(y.progress=e._reportProgress,y.token=e)}))}function y(n,i,o){function l(){if(s){var e=s.componentAssetPath(n,t._local());if("string"==typeof e)return m(n,e,o)}}var u=_.getRecordForUploadedComponent(n.id);if(u&&u["source-href"]===i)return n.etag=u.etag,n.version=u.version,n.md5=u.md5,n.length=u.length,void(n.state=d.unmodified);f(n,"copying"),e._session._getCopyDelegate(i,e._composite.href,(function(t,s){if(t)return l();var u=s(n.id,n.type,o,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,(function(e,t,o){if(e)return l();var r=v(t,o),a=r.etag,s=r.version,u=r.md5,h=r.length;a||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),s||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),u||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),h||(e=new c(c.UNEXPECTED_RESPONSE,"No length")),e||(n.etag=a,n.version=s,n.md5=u,n.length=h,n.state=d.unmodified,_.recordUploadedComponent(n.id,a,s,u,h,void 0,i),_.commitChanges()),f(n,null,e)}));u&&(u.progress=e._reportProgress,u.token=e)}))}for(i=0;i<o.length;++i){var g=o[i],E=g.state,O=!g.etag;if(E||(E=d.unmodified),O||E===d.modified){var A=t._core._getSourceHrefOfComponent(g);if(t.hasLocalStorage||A){var S=O||e._compositeIsNew;if(A)y(g,A,S);else{var b=s.componentAssetPath(g,t._local());"string"==typeof b&&m(g,b,S)}}else{var L=new c(c.INVALID_STATE,"Component should not be modified or new without local storage");e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:g,error:L})}}else E===d.unmodified?_.removeRecordForUploadedComponent(g.id):E!==d.committedDelete&&E!==d.pendingDelete||t.removeComponent(g)}0===Object.keys(l).length&&n()},i=function(e,t,n,i,o,r,s,l,u){if("function"!=typeof u)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var h=o.length||o.byteLength||o.size,p=new f(l,u);p.bytesTotal=h;var d=l.uploadAssetForComponentId(e,t,s,n,i,p,o,(function(n,i,o){var s;if(!n)try{s=new a._UploadResults(r),h=h||d.bytesSent,s.records[e]=function(e,t,n,i,o){if("number"!=typeof t)throw new c(c.UNEXPECTED_RESPONSE,"No length");var r=v(i,o),s=r.etag,l=r.version,u=r.md5;if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!l)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!u)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,s,l,u,t,n)}(e,h,t,i,o)}catch(e){n=e,s=void 0}p._xferComplete(n,s)}));return d&&(d.progress=p._reportProgress,d.token=p),p},o=function(e,t,n,i,o,r,s,l,u){if("function"!=typeof u)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var h=new f(l,u),p=l.copyAssetToComponentId(e,t,s,n,i,h,o,(function(n,i,o){if(!h._aborted){var s;if(!n)try{(s=new a._UploadResults(r)).records[e]=function(e,t,n,i){var o=v(i,t),r=o.etag,s=o.version,l=o.md5,u=o.length;if("number"!=typeof u)throw new c(c.UNEXPECTED_RESPONSE,"No length");if(!r)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!l)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,r,s,l,u,n)}(e,o,t,i)}catch(e){n=e,s=void 0}u(n,s)}}));return p&&(p.progress=h._reportProgress,p.token=h),h},e.exports=m},function(e,n,i){var o=i(12),r=i(13),a=i(0),s=i(2),c=i(5),l={isSnapshot:function(e,n){var i,o=!1,r=function(e,t){o||(o=!0,i&&i.isOpen&&i.close(),n(e,t))};(void 0).open(e,{lazyEntries:!0},(function(e,n){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?r(e):r(new a(a.INVALID_DATA,"Error while opening snapshot: "+e)):((i=n).on("entry",(function(e){"mimetype"===e.fileName?i.openReadStream(e,(function(e,n){if(e)r(e);else{var i=[];n.on("data",(function(e){i.push(e)})),n.on("error",(function(e){r(e)})),n.on("end",(function(){var e=t.concat(i).toString();e&&p(e,"dcxucf")?r(null,!0):r(null,!1)}))}})):r(null,!1)})).on("error",(function(e){r(e)})),i.readEntry())}))},importSnapshot:function(e,t,n,i,r,a){return this.importSnapshotToDirectory(e,t,n,i,r,(function(e,t){if(e)a(e);else try{var n=new o(null,null,t,null,null,null);n.loadCurrentFromLocalStorage((function(e){a(e,e?void 0:n)})),n.deleteTempFiles()}catch(e){a(e)}}))},importSnapshotToDirectory:function(e,n,i,o,l,u){var h,d,f,m,v=!1,y=0,g=0,E=0,O=!1,A=function(e,t){if(!O){if(O=!0,h&&h.isOpen&&h.close(),e)return t&&c.deleteDirectory(t),void u(e);u(e,t)}},S={},b={};return c.ensureDirectoryExists(n,(function(u){u?A(u):(void 0).open(e,{lazyEntries:!0},(function(e,u){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?A(e):A(new a(a.INVALID_DATA,"Error while opening snapshot: "+e)):((h=u).on("entry",(function(e){if(y++,g=0,E=0,_(e,o))if(1===y)"mimetype"===e.fileName?h.openReadStream(e,(function(e,n){if(e)A(e);else{var i=[];n.on("data",(function(e){i.push(e)})),n.on("error",(function(e){A(e)})),n.on("end",(function(){var e=t.concat(i).toString();e&&p(e,"dcxucf")||A(new a(a.INVALID_DATA,"Bad mimetype")),h.readEntry()}))}})):A(new a(a.INVALID_DATA,"Missing mimetype file"));else if(2===y)"manifest"===e.fileName?h.openReadStream(e,(function(e,n){if(e)A(e);else{var i=[];n.on("data",(function(e){i.push(e)})),n.on("error",(function(e){A(e)})),n.on("end",(function(){var e=t.concat(i).toString();if(e){if(d=JSON.parse(e),(f=new r(d))._resetIdentity(),o){var n=f.getComponentWithAbsolutePath("/META-INF/metadata.xml");n&&f.removeComponent(n)}m=d.id,h.readEntry()}else A(new a(a.INVALID_DATA,"Unable to parse manifest on import"))}))}})):A(new a(a.INVALID_DATA,"Missing manifest file"));else if(m){g=e.uncompressedSize;var i=n+"/"+m+"/components";c.ensureDirectoryExists(i,(function(t){t?A(t):h.openReadStream(e,(function(t,n){if(t)A(t);else{var o=s.generateUuid(),r=e.fileName.split("/"),a=r[r.length-1].split(".");a&&(o=o+"."+a[a.length-1]),S["/"+e.fileName]=o,n.on("end",(function(){h.readEntry()})),n.on("data",(function(e){E+=e.length,function(){if(!v){var e=(y-1)/h.entryCount;g&&(e+=E/(g*h.entryCount)),l(Math.round(100*e))}}()})).on("error",(function(e){A(e)})).pipe(c.createWriteStream(i+"/"+o))}}))}))}else A(new a(a.INVALID_DATA,"Missing manifest id"));else h.readEntry()})).on("error",(function(e){A(e)})).on("close",(function(){O||(v?A(new a(a.UNEXPECTED,"Import cancelled")):(Object.keys(S).forEach((function(e){var t=f.getComponentWithAbsolutePath(e);t&&(b[t.id]=S[e])})),d.local||(d.local={}),d.local["copyOnWrite#storageIds"]=b,i&&(d.local.compositeHref=i(d.id)),m?c.ensureDirectoryExists(n+"/"+m,(function(e){e?A(e):c.writeFile(n+"/"+m+"/manifest",JSON.stringify(d,void 0,2),(function(e){e?A(e):A(null,n+"/"+m)}))})):A(new a(a.INVALID_DATA,"Missing manifest id"))))})),h.readEntry())}))})),function(){v||(v=!0,h&&h.close())}},exportSnapshot:function(e,n,i,o,r){var l,h,d=!1,_=function(e){if(!d){if(d=!0,e)return void c.deleteFile(h,(function(){return r(e)}));c.move(h,n,!1,(function(e){return r(e||null)}))}};try{h=n.replace(/([^\\/]+)$/,"."+s.generateUuid()+"_$1"),l=c.createWriteStream(h)}catch(e){return void _(e)}var f,m=new(void 0).ZipFile;if(e.type&&p(e.type,"dcx")){f=e.type+"ucf",m.addBuffer(t.from(f),"mimetype",{compress:!1});var y=u(e.current,i),g=JSON.stringify(y.manifest,void 0,2),E=y.lengths.total+g.length;m.addBuffer(t.from(g),"manifest",{compress:!0});var O=y.componentMap,A=y.components.map((function(t){return{id:t.id,path:O&&O[t.id]||t.path,type:t.type,absolutePath:e.current.getComponentWithId(t.id).absolutePath.substring(1)}})).sort((function(e,t){return e.absolutePath<t.absolutePath?-1:e.absolutePath>t.absolutePath?1:0})),S=!1,b=0;return A.forEach((function(t){var n=e.path+"/components/"+t.path;v(t.type)?m.addFile(n,t.absolutePath,{compress:!0}):m.addFile(n,t.absolutePath,{compress:!1})})),m.end(),m.on("error",(function(){_(new a(a.INVALID_DATA,"Missing component file locally."))})),m.outputStream.on("error",(function(e){_(S?new a(a.UNEXPECTED,"Export cancelled"):e)})).on("data",(function(e){b+=e.length,S||o(Math.min(100,Math.round(100*b/E)))})).pipe(l).on("close",(function(){_(S?new a(a.UNEXPECTED,"Export cancelled"):null)})).on("error",(function(e){_(e)})),function(){S||(S=!0,m.outputStream.end())}}_(new a(a.INVALID_PARAMS,"Invalid composite type"))}},u=function(e,t){var n=JSON.parse(e.localData);t&&t(n);var i=h(n,n.local["copyOnWrite#storageIds"]||{});return delete n.local,delete n.manifestEtag,n.state="unmodified",{manifest:n,lengths:i.lengths,componentMap:i.componentMap,components:i.components}},h=function e(t,n,i,o,r){return r=r||[],i=i||{},o=o||{total:0},t.components&&t.components.forEach((function(e){i[e.id]=n[e.id];var t=e.length||1e5;o[e.id]=t,o.total+=t,e.state="unmodified",delete e.version,delete e.md5,delete e.etag,r.push(e)})),t.children&&t.children.forEach((function(t){e(t,n,i,o,r)})),{lengths:o,componentMap:i,components:r}},p=function(e,t){var n=e.split("/");if(2===n.length){var i=n[1];if(i.length<t.length+2)return!1;if(i.substring(i.length-t.length)!==t)return!1;var o=i.length-(t.length+1);return"+"===i.charAt(o)}return!1},d=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\.[^/\\]+$/i,_=function(e,t){if("mimetype"===e.fileName||"manifest"===e.fileName)return!0;var n=e.fileName.split("/");if(n){var i=n[n.length-1];return!t&&"metadata.xml"===i||i.match(d)}return!1},f=["text/"],m=["+json","+xml"],v=function(e){return f.forEach((function(t){if(e.startsWith(t))return!0})),m.forEach((function(t){if(e.endsWith(t))return!0})),!1};e.exports=l},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,o)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function s(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function c(e,t,n){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var h=n(30),p=n(1),d=n(3),_=function(e){function t(){return r(this,t),s(this,l(t).apply(this,arguments))}var n,i,h,_;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(t,e),n=t,(i=[{key:"_dosync",value:function(e,t){var n=this;this._clearSyncErrors(),this._syncManager.getServerComposites(this,(function(i,o,r){if(i)return i=d.getSyncError(i,void 0,{403:p.ACCESS_DENIED}),n._reportSyncError(i),void t(null,!1);o=o.filter((function(e){return!e.collaboration||"incoming"!==e.collaboration.toLowerCase()}));var a=[];if(a.push(n._syncNewLibraries(o)),a.push(n._syncExistingLibraries(r,e)),a.push(n._handlePendingDeletes()),!e){var s=n._bookmarkManager.sync().then((function(){return!1}));a.push(s)}a.push(n._getUserQuota()),Promise.all(a).then((function(e){n._handleExternalPendingDeletes(),t(null,e.some((function(e){return e})))}))}))}},{key:"_getUserQuota",value:(h=regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._userQuota||this._fetchingUserQuota){e.next=14;break}return e.prev=1,this._fetchingUserQuota=!0,e.next=5,this._syncManager.getUserQuota();case 5:this._userQuota=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),this._services.log("Unable to get user quota. Error: ".concat(e.t0));case 11:return e.prev=11,this._fetchingUserQuota=!1,e.finish(11);case 14:case"end":return e.stop()}}),e,this,[[1,8,11,14]])})),_=function(){var e=this,t=arguments;return new Promise((function(n,i){var r=h.apply(e,t);function a(e){o(r,n,i,a,s,"next",e)}function s(e){o(r,n,i,a,s,"throw",e)}a(void 0)}))},function(){return _.apply(this,arguments)})},{key:"_ensureDefaultLibrary",value:function(){var e="ok"===this.syncState&&!this.isInitialSyncInProgress&&this._config.SYNCING_ENABLED,t=this.libraries.some((function(e){return!e.isDeletedLocally&&!e.isDeletedFromServer&&!e.toolkitId}));if(e&&!t){var n=this._localisation.translate("LIBS_DEFAULT_LIBRARY_NAME");this._services.log("Creating default library: "+n),this.createLibrary(n)}}},{key:"_updateSyncState",value:function(){c(l(t.prototype),"_updateSyncState",this).call(this),this._ensureDefaultLibrary()}},{key:"_shouldOmitComposite",value:function(e){return"sharedWithUser"===e.collaborationType}},{key:"createLibrary",value:function(e){return c(l(t.prototype),"createLibrary",this).call(this,e,void 0)}},{key:"createBookmark",value:function(e,t,n,i){var o=this._isBookmarkDataInvalid(e,n);if(o)return i(o);this._bookmarkManager.createBookmark(e,t,n,void 0,i)}},{key:"_isBookmarkDataInvalid",value:function(e,t,n){var i=this._config.BOOKMARKS_TYPES[e];if(!i)return new p(p.INVALID_PARAMETER,"unsupported bookmark type: ".concat(e));var o=i.allowed,r=i.required;return r&&!Array.isArray(r)&&(r=n&&r[n.condition]||r.default),(!r.every((function(e){return"string"==typeof t[e]}))||!Object.keys(t).every((function(e){return o.includes(e)})))&&new p(p.INVALID_PARAMETER,"bookmarks of type ".concat(e," must have the following data keys: ").concat(o.join(", ")))}},{key:"removeBookmark",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0;this._bookmarkManager.removeBookmark(e,void 0,t,n)}},{key:"findBookmark",value:function(e){return this._bookmarkManager.findBookmark(e)}},{key:"syncBookmarks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this._bookmarkManager.sync().then((function(){return e()}))}},{key:"addBookmarkChangeListener",value:function(e){this._bookmarkManager.addChangeListener(e)}},{key:"removeBookmarkChangeListener",value:function(e){this._bookmarkManager.removeChangeListener(e)}},{key:"addPlatformFolderChangeListener",value:function(e){this._platformManager.addChangeListener(e)}},{key:"removePlatformFolderChangeListener",value:function(e){this._platformManager.removeChangeListener(e)}},{key:"getDefaultLibrary",value:function(){return this.libraries.reduce((function(e,t){var n=!e||(e.created||0)>(t.created||0);return t._collection.isPrivate&&n?t:e}),void 0)}},{key:"getToolkitLibrary",value:function(e){var t=this._libraries.filter((function(t){return t.toolkitId===e}));if(!t.length){var n=this.createLibrary(this._localisation.getToolkitName(e));return n.setValue(this._config.TOOLKIT_NAMESPACE,this._config.TOOLKIT_ID_KEY,e),n}return t.sort((function(e,t){return e.created-t.created})),t[0]}},{key:"bookmarks",get:function(){return this._bookmarkManager.getBookmarks()}},{key:"fontManager",get:function(){return this._fontManager}},{key:"userQuota",get:function(){return this._userQuota}},{key:"storageUsed",get:function(){return this._libraries.reduce((function(e,t){return e+t.storageUsed}),0)}}])&&a(n.prototype,i),t}(h);e.exports=_},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(0),u=n(8),h=n(2),p=n(31),d=n(18),_=n(17),f=n(1),m=n(39),v=n(6),y=n(3),g=n(40),E=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments))}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"_syncNewLibraries",value:function(e){var t=this;this._loadingHint&&(e=e.slice()).sort((function(e,n){return Number(t._loadingHint.includes(n.name))-Number(t._loadingHint.includes(e.name))}));var n=(e=e.filter((function(e){return!t._doesLibraryExist(e.name)}))).map((function(e){return new Promise((function(n){t._syncNewLibrary(e.name,void 0,e,(function(e,i){e&&t._reportSyncError(e),n(i)}))}))}));return Promise.all(n).then((function(e){return e.some((function(e){return e}))}))}},{key:"_syncExistingLibraries",value:function(e,t){var n=this,i=[];return this._libraries.forEach((function(o){var r=e&&e[o.id];if(r&&(o._setAssetId(r.urn),o._setCollaboration(r),o._deletedFromServer&&(o._deletedFromServer=!1,o._notifyChange())),t)(t[o.id]||r&&!r.isUnmodified)&&i.push((function(e){return o._sync(!1,e)}));else{var a=!e||r&&r.isUnmodified;void 0===o.collaboration?i.push((function(e){return o._sync(a,e)})):a?i.push((function(e){n._syncManager.hasCompositeChangedOnServer(o._dcxComposite,(function(t){o._sync(!t,e)}))})):i.push((function(e){return o._sync(!1,e)}))}})),Promise.all(i.map((function(e){return new Promise((function(t){e((function(e,i){e&&n._reportSyncError(e),t(i)}))}))}))).then((function(e){return e.some((function(e){return e}))}))}},{key:"_handlePendingDeletes",value:function(){var e=this,t=this._pendingDeletes.map((function(t){return new Promise((function(n){var i,o=t._dcxBranch.getLocalData("pendingOperation");if(o&&"remove"===o.operation){var r=o.condition,a=e._apiRoot.getLoadedCollections().find((function(e){return e.cloudId===r.cloudId}));if(!(i=a&&a.getLibraryById(r.libraryId)))return t._dcxBranch.setLocalData("pendingOperation"),t._dcxBranch.compositeState="modified",e._libraries.push(t),e._libraryIdMap[t.id]=t,e._removeFromPendingDeletes(t),e._notifyChange(!0),t._commit(!1,!0),void n(!0);if("on_pushed_new"!==r.condition||!i._dcxBranch.isBound)return n(!1)}e._removeFromPendingDeletes(t),e._activeDeletes.push(t),t._deleteFromServer(!1,(function(r){var a=function(i){return e._reportSyncError(i),e._removeFromActiveDeletes(t),e._pendingDeletes.push(t),n(!1)},s=function(i){if(i)return a(i);t._deletedFromDisk=!0,e._services.fileUtils.deleteLibraryFromDisk(e,t.id,(function(i){i&&e._reportSyncError(i),e._removeFromActiveDeletes(t),n(!0)}))};if(r&&r.code===l.UPDATE_CONFLICT)return o&&i?void t._pull((function(e){if(e)return a(e);v.recoverReadOnlyEdits(t,i._dcxBranch,(function(e){if(e)return a(e);t._deleteFromServer(!0,s)}))})):(e._libraries.push(t),e._libraryIdMap[t.id]=t,t._markDeletedLocally(!1),e._removeFromActiveDeletes(t),e._updateSyncState(),e._notifyChange(!0),void n(!0));s(r)}))}))}));return Promise.all(t).then((function(e){return e.some((function(e){return e}))}))}},{key:"_handleExternalPendingDeletes",value:function(){var e=this;return Promise.all(this._apiRoot.getLoadedCollections().map((function(t){return t!==e&&t._handlePendingDeletes?t._handlePendingDeletes():Promise.resolve(!1)}))).then((function(e){return e.some((function(e){return e}))}))}},{key:"_removeFromPendingDeletes",value:function(e){var t=this._pendingDeletes.indexOf(e);-1!==t&&this._pendingDeletes.splice(t,1)}},{key:"_removeFromActiveDeletes",value:function(e){var t=this._activeDeletes.indexOf(e);-1!==t&&this._activeDeletes.splice(t,1)}},{key:"_dosync",value:function(e,t){var n=this;this._clearSyncErrors(),this._syncManager.getServerComposites(this,(function(i,o,r){if(i)return i=y.getSyncError(i,void 0,{403:f.ACCESS_DENIED}),n._reportSyncError(i),void t(null,!1);var a=[];a.push(n._syncNewLibraries(o)),a.push(n._syncExistingLibraries(r,e)),a.push(n._handlePendingDeletes()),Promise.all(a).then((function(e){n._handleExternalPendingDeletes(),t(null,e.some((function(e){return e})))}))}))}},{key:"_doRemoveLibrary",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},i=this._libraries.indexOf(e);if(-1!==i&&(this._libraries.splice(i,1),delete this._libraryIdMap[e.id]),e._removeAllListeners(),this._config.SHARED_LOCAL_STORAGE)this._prepareCompositeForDelete(e._dcxComposite),e._commit(!1,!0),e._markDeletedLocally(!0),n(null);else{this._pendingDeletes.push(e);var o=e._dcxComposite&&e._dcxComposite.getLocalData("pendingOperation");o?(this._prepareCompositeForDelete(e._dcxComposite),e._commit(!0,!0),n(null)):this._config.SYNCING_ENABLED?e._deleteFromServer(!0,(function(i){e._markDeletedLocally(!0),i?n(null):(t._removeFromPendingDeletes(e),e._deletedFromDisk=!0,t._services.fileUtils.deleteLibraryFromDisk(t,e.id,n))})):(this._prepareCompositeForDelete(e._dcxComposite),e._commit(!0,!0),e._markDeletedLocally(!0),n(null))}this._notifyChange(!0)}},{key:"_doImportLibrary",value:function(e,t,n){var i,o=this;if(this._config.SHARED_LOCAL_STORAGE){var r=this._services.uuid();return this._storageInterface.importLibrary(this,e,r,t),this._addOperation(r,"import")}var a=this._addOperation(n||this._services.uuid(),"import",void 0,(function(){return i&&i()}));return i=g.importLibrary(this,e,(function(e){return a._updateProgress(e)}),(function(e,n){a._updateProgress(100),o._removeOperation(a),t(e,n)})),a}},{key:"_pushNewLibrary",value:function(e){this._libraries.push(e),this._libraryIdMap[e.id]=e,this._notifyChange(!0),e._commit(!1,!0)}},{key:"createLibrary",value:function(e,t){var n=this._services.uuid(),i=this._config.COMPOSITE_TYPE,o=this._getCompositeDir(n),r=this._services.dcx.newEmptyComposite(e,i,o,n);r.current.rootNode.setValue(this._config.VERSION_KEY,this._config.VERSION),this._prepareCompositeForPush(r,t);var a=new _(this,r);return a._updateCreatedTime(),this._pushNewLibrary(a),this._analytics.reportCreateLibrary(a),a}},{key:"removeLibrary",value:function(e,t){this._doRemoveLibrary(e,t),this._analytics.reportDeleteLibrary(e)}},{key:"moveLibrary",value:function(e,t,n){var i=this,o=this._apiRoot.getLoadedCollections().find((function(e){return e.isCollaborated}));e?this._libraries.includes(e)?o?this!==o?this.isCollaborated?n(new f(f.NOT_ALLOWED,"Source collection cannot be a collaborated collection")):t instanceof m?t.isWritable?"incoming"!==e.collaboration?this._config.SHARED_LOCAL_STORAGE?this._storageInterface.moveLibrary(e,t,n):this._syncManager.removeAllCollaborators(e).then((function(){i._services.dcx.copyCompositeAndAssetsFrom(e._dcxComposite,void 0,void 0,o._getCompositeDir()+"/"+e.id,e.id,h.getTemplateFromLinks(t.links,u.CREATE),(function(r,a){if(r)return n(r);o._prepareCompositeForPush(a,t);var s=new _(o,a);e._dcxBranch.setLocalData("pendingOperation",{operation:"remove",condition:{condition:"on_pushed_new",cloudId:o.cloudId,libraryId:s.id}}),s._renditionCache.copyFullCache(e).then((function(){i._doRemoveLibrary(e,(function(){o._pushNewLibrary(s),n(null,s)}));var t=d.waitForPushNew(s.id);o._bookmarkManager.createBookmark("collab",s.id,{},t)}))}))}),n):n(new f(f.NOT_ALLOWED,"moving can only be done to owned libraries")):n(new f(f.NOT_ALLOWED,"You do not have write access to the destination folder")):n(new f(f.INVALID_PARAMETER,"Missing platform folder parameter")):n(new f(f.INVALID_PARAMETER,"Library is already in the target collection")):n(new f(f.INVALID_PARAMETER,"No collaborated collection found")):n(new f(f.INVALID_PARAMETER,"Library not in this collection")):n(new f(f.INVALID_PARAMETER,"No library specified"))}},{key:"importLibrary",value:function(e,t){var n=this;if("string"==typeof e){if(this._config.SHARED_LOCAL_STORAGE||this._services.hasFileSystem())return this._doImportLibrary(e,(function(e,i){n._analytics.reportImportLibrary(e,i),t(e,i)}));t(new f(f.REQUIRES_FILESYSTEM,"importLibrary only supported when you have a filesystem"))}else t(new f(f.INVALID_PARAMETER,"path must be a string"))}},{key:"isPublic",get:function(){return!1}}])&&r(n.prototype,i),t}(p);e.exports=E},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(0),r=n(2),a=n(17),s=n(72),c=n(1),l=n(77),u=n(18),h=n(80),p=n(81),d=n(6),_=n(3),f=n(40),m=n(7),v=n(83),y=n(4).promisify,g=function(){function e(t,n,i){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._apiRoot=t,this._userId=n.USER_ID,this._userProfile=n.USER_PROFILE,this._cloudId=n.CLOUD_ID,this._privateCollection=i||this,this._bookmarkManager=i?i._bookmarkManager:new u(this),this._fontManager=i?i._fontManager:new h(this),this._platformManager=i?i._platformManager:new p(this),this._syncManager=(i||this)._getSyncManager(n),this._libraries=[],this._syncState="syncing",this._syncProgressMap={},this._externalLinkDownloadProgressMap={},this._initialSyncInProgress=!1,this._syncErrors=[],this._listenerManager=new m(["change","deepchange","sync","operation","commitError"],(function(e){return o._services.log(e)})),this._operations=[],v.connect(this),this._libraryIdMap={},this._operationIdMap={},this._removeOperationTimeout={},this._pendingDeletes=[],this._activeDeletes=[],this._loaded=!1,this._syncing=!1,this._lastSyncTime=0,this._pendingSyncs=[],this._backoffTicks=0,this._numBackoffs=0,this._numRetries=0,this._recoveredLibraryCount=0,this._newLibrariesLoading={},this._partialSyncedNewLibraries={}}var t,n;return t=e,(n=[{key:"_dispose",value:function(){v.disconnect(this)}},{key:"_getSyncManager",value:function(e){return this._syncManagers=this._syncManagers||{},this._syncManagers[e.STORAGE_HOSTNAME]||(this._syncManagers[e.STORAGE_HOSTNAME]=new s(this._apiRoot,e)),this._syncManagers[e.STORAGE_HOSTNAME]}},{key:"_getNewCompositeHref",value:function(e){return r.appendPathElements(this._href,e)}},{key:"_prepareCompositeForPush",value:function(e,t){e.href=this._getNewCompositeHref(e.id,t)}},{key:"_prepareCompositeForDelete",value:function(e){e._current.compositeState=this.links?"pendingDiscard":"pendingDelete"}},{key:"_removeAllListeners",value:function(){this._listenerManager.removeAll(),this._libraries.forEach((function(e){return e._removeAllListeners()}))}},{key:"_notifyChange",value:function(e){this._listenerManager.notify("deepchange"),e&&this._listenerManager.notify("change")}},{key:"_cleanLocalData",value:function(){var e=this,t=this._apiRoot._getPrivateCollection(this.userId);if("ok"!==this.syncState||t&&"ok"!==t.syncState)return Promise.resolve();var n=Object.keys(this._partialSyncedNewLibraries);return this._partialSyncedNewLibraries={},n.length>0&&this._services.log("Deleting local data for partial library sync: ".concat(n.join(", "))),Promise.all(n.map((function(t){return new Promise((function(n){e._services.fileUtils.deleteLibraryFromDisk(e,t,(function(){return n()}))}))})))}},{key:"_loadLibrary",value:function(e,t){var n=this,i=this._getCompositeDir(e),o=function(i){n._services.log("Load error: ".concat(i)),n._services.fileUtils.deleteLibraryFromDisk(n,e,(function(){return t(null)}))},r=function(i){var o=new a(n,i,n.isPublic&&e);"pendingDelete"===i.current.compositeState?(n._pendingDeletes.push(o),t(null)):(n._libraries.push(o),n._libraryIdMap[o.id]=o,o._renditionCache.load().then(t))};this._services.dcx.newCompositeFromLocalStorage(i,(function(i,a){return i||!a?o("DCX error loading composite for ".concat(e)):n._shouldOmitComposite(a)?(n._services.log("Library is explicitly omitted from collection: ".concat(e)),t(null)):a.current?n.isPublic||a.id===e?void(a.href&&a.current.isBound?a.loadBaseBranch((function(t,n){t||!n?o("missing base branch for ".concat(e," (even though bound to server)")):r(a)})):r(a)):o("library id ".concat(a.id," doesn't match folder on disk ").concat(e)):(n._services.log("Found incomplete pull of new library: ".concat(e)),n._partialSyncedNewLibraries[e]=!0,t(null))}))}},{key:"_shouldOmitComposite",value:function(){return!1}},{key:"_load",value:function(e,t){var n=this;this._loaded?e(null):(this._loaded=!0,(this.isPrivate?this._platformManager.load():Promise.resolve()).then((function(){n._services.fileUtils.readLibraryDirectory(n,(function(i,o){if(!i&&o)if(!t&&!n.isPublic&&o.length>=n._config.ELMO_LOCAL_LIBRARY_LIMIT)d.recoverFromElmo(n,o,(function(){n._loaded=!1,n._load(e,!0)}));else{var r=[];o.forEach((function(e){if(d.validateLibraryId(e,n.isPublic)){var t=y(n._loadLibrary.bind(n))(e).catch((function(e){return n._reportCommitError(e)}));r.push(t)}})),r.push(n._externalLinkCache.load()),n.isPrivate&&r.push(n._bookmarkManager.load()),Promise.all(r).then((function(){n._services.log("Loaded "+n._libraries.length+" libraries and "+n._pendingDeletes.length+" pending deletes"),e(null)}))}else e(null)}))})))}},{key:"_getLocalLibraryById",value:function(e){return this._libraryIdMap[e]||this._pendingDeletes.find((function(t){return t.id===e}))||this._activeDeletes.find((function(t){return t.id===e}))}},{key:"_doesLibraryExist",value:function(e){return void 0!==this._getLocalLibraryById(e)}},{key:"_syncNewLibrary",value:function(e,t,n,i){var o=t||this._getNewCompositeHref(e),r=this._services.hasFileSystem()&&this._getCompositeDir(e),a=this._services.dcx.newCompositeWithHref(o,r);return this._syncNewLibraryWithComposite(e,a,n,i)}},{key:"_syncNewLibraryWithComposite",value:function(e,t,n,i){var r=this;delete this._partialSyncedNewLibraries[e],this._libraryIdMap[e]="pending",this._updateSyncState(),n&&n.urn&&(t.assetId=n.urn);var s={id:e,_dcxComposite:t,collection:this};this._syncManager.pullLibrary(s,(function(s,l){if(s||!l)return delete r._libraryIdMap[e],r._updateSyncState(),s=s?s.code===o.NO_COMPOSITE||s.code===o.DELETED_COMPOSITE?null:_.getSyncError(s,e):new c(c.NETWORK_ERROR,"No pulled branch"),void i(s,!0);t.resolvePullWithBranch(l,(function(o){if(o||!r.isPublic&&t.id!==e)return delete r._libraryIdMap[e],r._updateSyncState(),o=o?_.getCommitError(o,e):new c(c.CORRUPTED_LIBRARY,"Library id does not match sync group id"),void i(o,!0);var s=new a(r,t,r.isPublic&&e);r._libraries.push(s),r._libraryIdMap[s.id]=s,r._updateSyncState(),s._setCollaboration(n),s._prefetchRenditions(),r._notifyChange(!0),i(null,!0)}))}))}},{key:"_reportSyncError",value:function(e){e&&(this._services.log("Sync error: "+_.errorToString(e)),this._syncErrors.push(e))}},{key:"_clearSyncErrors",value:function(e){this._syncErrors=e?this._syncErrors.filter((function(t){return t.libraryId!==e})):[]}},{key:"_reportCommitError",value:function(e){this._lastCommitError=e,e&&(this._services.log("Commit error: "+_.errorToString(e)),this._listenerManager.notify("commitError",[e]))}},{key:"_updateRetryState",value:function(){var e=this;if(!this._retryTimeoutId&&"syncing"!==this._syncState){if("error"===this._syncState){var t=this.getPrimarySyncError();if(t&&t.code===c.RETRYABLE_SERVER_ERROR){if(this._numRetries++,this._numRetries>this._config.ERROR_RETRY_INTERVALS.length)return this._retryTime="never",this._services.log("Retry Failed"),void(this._config.MAX_SYNC_INTERVAL=this._config.RETRY_FAIL_MAX_SYNC_INTERVAL);this._services.log("Retry "+this._numRetries);var n=t.underlyingError&&t.underlyingError.response&&t.underlyingError.response.headers,i=1e3*this._config.getRetryAfterHeader(n);return i>0?(this._numRetries=this._config.ERROR_RETRY_INTERVALS.length,this._services.log("Got Retry-After header")):i=1e3*this._config.ERROR_RETRY_INTERVALS[this._numRetries-1],this._services.log("Retrying after "+i+"ms"),this._retryTime=Date.now()+i,void(this._retryTimeoutId=setTimeout((function(){e._retryTimeoutId=void 0,e._retryTime=void 0,e._services.log("Starting retry"),e._syncWithParameters(!1)}),i))}if(t&&t.code===c.EXCEEDS_QUOTA)return this._config.MAX_SYNC_INTERVAL=this._config.RETRY_FAIL_MAX_SYNC_INTERVAL,this._numRetries=this._config.ERROR_RETRY_INTERVALS.length+1,void(this._retryTime="never")}this._numRetries=0,this._retryTime=void 0}}},{key:"_setInitialSyncState",value:function(e,t){this._initialSyncInProgress=e,this._loadingHint=t,this._updateSyncState()}},{key:"_resetPollBackoff",value:function(){this._backoffTicks=0,this._numBackoffs=0}},{key:"_updateSyncState",value:function(){var e=this,t="syncing";this._initialSyncInProgress||Object.keys(this._libraryIdMap).some((function(t){var n=e._libraryIdMap[t];return"pending"===n||n._isSyncing()}))||(this._syncErrors.length>0?(t="error",this._syncManager.clearSyncGroupCache(),this._analytics.reportError(this.getPrimarySyncError())):t="ok",this._syncProgressMap={},this._syncProgress=void 0);var n=this._syncState;this._syncState=t,this._updateRetryState(),n===t&&"error"!==this._syncState||this._listenerManager.notify("sync")}},{key:"_updateProgress",value:function(e,t,n){n?this._syncProgressMap[e]={bytesLoaded:t||0,bytesTotal:n,progress:this._syncProgressMap[e]&&this._syncProgressMap[e].progress}:this._syncProgressMap[e]?(0===this._syncProgressMap[e].bytesTotal&&(this._syncProgressMap[e].bytesTotal=1e4),this._syncProgressMap[e].bytesLoaded=this._syncProgressMap[e].bytesTotal):this._syncProgressMap[e]={bytesLoaded:0,bytesTotal:0};var i=!1,o=t||0,r=(n||0)>0?Math.max(0,Math.min(100,Math.round(o/n*100))):void 0;this._syncProgressMap[e].progress!==r&&(this._syncProgressMap[e].progress=r,i=!0);var a=0,s=0,c=0,l=0,u=this._syncProgressMap;Object.keys(u).forEach((function(e){a++,u[e].bytesTotal>0&&s++,c+=u[e].bytesLoaded,l+=u[e].bytesTotal}));var h=l>0?c*s/(l*a):0,p=Math.max(0,Math.min(100,Math.round(100*h)));(!this._syncProgress||this._syncProgress<p||100===this._syncProgress&&p<100)&&(this._syncProgress=p,i=!0),i&&this._listenerManager.notify("sync")}},{key:"_updateExternalLinkDownloadProgress",value:function(e,t,n,i){var o,r=e.element.library.id+"."+e.element.id+"."+e.id;n?(t=t||0,o=Math.max(0,Math.min(100,Math.round(t/n*100)))):i&&(o=-1),o!==this._externalLinkDownloadProgressMap[r]&&(void 0===o?delete this._externalLinkDownloadProgressMap[r]:this._externalLinkDownloadProgressMap[r]=o,this._listenerManager.notify("sync"))}},{key:"_getExternalLinkDownloadProgress",value:function(e){var t=e.element.library.id+"."+e.element.id+"."+e.id;return this._externalLinkDownloadProgressMap[t]}},{key:"_abortPushOrPull",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Object.keys(this._libraryIdMap).forEach((function(t){var n=e._libraryIdMap[t];"pending"===n?e._syncManager.abortPushOrPull(t):n._abortPushOrPull()})),this._pendingDeletes.forEach((function(e){return e._abortPushOrPull()}));var n=this._pendingSyncs;this._pendingSyncs=[],n.forEach((function(e){return e(new c(c.TRANSFER_ABORTED,"abort push or pull operation"))})),t&&this._syncManager.abortAllDownloads()}},{key:"_getBaseDir",value:function(){var e=this._services.getPathSeparator();return this._services.fileUtils.getUserDir(this._userId)+e+this._directoryName}},{key:"_getLibraryDir",value:function(e,t){var n=this._services.getPathSeparator(),i=this._getBaseDir()+n+e;return t&&(i+=n+t),i}},{key:"_getCompositeDir",value:function(e){return this._getLibraryDir("dcx",e)}},{key:"_getTempDir",value:function(){var e=this._services.getPathSeparator();return this._getBaseDir()+e+".tmp"}},{key:"_getRenditionCacheDir",value:function(e){return this._getLibraryDir("renditions",e)}},{key:"_addOperation",value:function(e,t,n,i){var o=new l(this,e,t,n,i);return this._operations.push(o),this._operationIdMap[o.id]=o,this._notifyOperationChange(),o}},{key:"_removeOperation",value:function(e){var t=this._operations.indexOf(e);-1!==t&&(this._operations.splice(t,1),delete this._operationIdMap[e.id]),this._notifyOperationChange()}},{key:"_delayedRemoveOperation",value:function(e){var t=this;this._removeOperationTimeout[e.id]||(this._removeOperationTimeout[e.id]=setTimeout((function(){delete t._removeOperationTimeout[e.id],t._removeOperation(e)}),this._config.REMOVE_OPERATION_TIMEOUT))}},{key:"_updateOperation",value:function(e,t,n,i){this._operationIdMap[e]||this._addOperation(e,t,n),this._removeOperationTimeout[e]&&(clearTimeout(this._removeOperationTimeout[e]),delete this._removeOperationTimeout[e]),this._operationIdMap[e]._updateProgress(i)}},{key:"_notifyOperationChange",value:function(){this._listenerManager.notify("operation")}},{key:"_doExportLibrary",value:function(e,t,n,i){var o,r=this;if(this._config.SHARED_LOCAL_STORAGE){var a=this._services.uuid();return this._storageInterface.exportLibrary(e,t,a,n),this._addOperation(a,"export",{libraryId:e.id})}i=i||this._services.uuid(),e._setAutoGC("export_"+i,!1);var s=this._addOperation(i,"export",{libraryId:e.id},(function(){return o&&o()}));return o=f.exportLibrary(e,t,(function(e){return s._updateProgress(e)}),(function(t){s._updateProgress(100),r._removeOperation(s),e._setAutoGC("export_"+i,!0),n(t)})),s}},{key:"_syncWithParameters",value:function(e,t,n,i){var o=this,r=function(){return i&&i(null)};if(this._config.SHARED_LOCAL_STORAGE)return this._storageInterface.sync(this),void r();this._config.SYNCING_ENABLED&&!this._retryTimeoutId?(e||this._resetPollBackoff(),this._syncing?this.isPolling?r():this._pendingSyncs.push(r):Date.now()<this._lastSyncTime+this._config.MAX_SYNC_INTERVAL?t?r():setTimeout((function(){return o._syncWithParameters(e,!0,n,r)}),this._config.MAX_SYNC_INTERVAL):(this._services.log("Start Sync: "+this.cloudId+(e?" [polling]":"")),this._syncing=!0,this._lastSyncTime=Date.now(),this._dosync(n,(function(e,t){o._updateSyncState(),o._cleanLocalData().then((function(){return function(e,t){if(o._syncing=!1,o._services.log("End Sync: "+o.cloudId),t&&o._resetPollBackoff(),o._pendingSyncs.length>0){var n=o._pendingSyncs;o._pendingSyncs=[],o.sync((function(){return n.forEach((function(e){return e()}))}))}r()}(0,t)}))})))):r()}},{key:"addChangeListener",value:function(e){this._listenerManager.add("change",e)}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e)}},{key:"addDeepChangeListener",value:function(e){this._listenerManager.add("deepchange",e)}},{key:"removeDeepChangeListener",value:function(e){this._listenerManager.remove("deepchange",e)}},{key:"addOperationChangeListener",value:function(e){this._listenerManager.add("operation",e)}},{key:"removeOperationChangeListener",value:function(e){this._listenerManager.remove("operation",e)}},{key:"addSyncListener",value:function(e){this._listenerManager.add("sync",e)}},{key:"removeSyncListener",value:function(e){this._listenerManager.remove("sync",e)}},{key:"addCommitErrorListener",value:function(e){this._listenerManager.add("commitError",e)}},{key:"removeCommitErrorListener",value:function(e){this._listenerManager.remove("commitError",e)}},{key:"removeDeletedLibraries",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};"function"==typeof e&&(n=e,e=void 0);var i=e&&e.exclude||[],o=function(e){var n=t._libraries.indexOf(e);return-1!==n&&(t._libraries.splice(n,1),delete t._libraryIdMap[e.id]),e._deletedFromDisk=!0,e._markDeletedLocally(!0),y(t._services.fileUtils.deleteLibraryFromDisk.bind(t._services.fileUtils))(t,e.id)},r=this._libraries.filter((function(e){return e.isDeletedFromServer&&i.every((function(t){return e!==t}))})).map((function(e){return o(e)})),a=function(e){r.length>0&&t._notifyChange(!0),n(e)};Promise.all(r).then((function(){return a(null)}),a)}},{key:"exportLibrary",value:function(e,t,n){var i=this;if(-1!==this._libraries.indexOf(e))if("string"==typeof t)if(0===t.length||t[t.length-1].match(/\\|\//))n(new c(c.INVALID_PARAMETER,"path must end in a filename"));else{if(t.substring(t.length-this._config.EXPORT_EXTENSION.length)!==this._config.EXPORT_EXTENSION&&(t+=this._config.EXPORT_EXTENSION),this._config.SHARED_LOCAL_STORAGE||this._services.hasFileSystem())return this._doExportLibrary(e,t,(function(t){i._analytics.reportExportLibrary(t,e),n(t)}));n(new c(c.REQUIRES_FILESYSTEM,"exportLibrary only supported when you have a filesystem"))}else n(new c(c.INVALID_PARAMETER,"path must be a string"));else n(new c(c.INVALID_PARAMETER,"library not in this collection"))}},{key:"sync",value:function(e){this._syncWithParameters(!1,!1,void 0,e)}},{key:"syncChanges",value:function(e,t){var n={};(e=e||[]).forEach((function(e){return n[e]=!0})),this._syncWithParameters(!1,!1,n,t)}},{key:"syncFull",value:function(e){this._syncManager.clearSyncGroupCache(),this._syncWithParameters(!1,!1,void 0,e)}},{key:"getPrimarySyncError",value:function(){var e=this._syncErrors[0];return this._syncErrors.forEach((function(t){var n=_.getErrorPriority(t),i=_.getErrorPriority(e);n>i?e=t:n===i&&e.code===t.code&&e.libraryId!==t.libraryId&&(e=new c(e.code,"multiple errors (see libraryCollection.syncErrors)",void 0))})),e}},{key:"getNewLibrarySyncProgress",value:function(){var e=this;return this._newLibraryProgress?this._newLibraryProgress:Object.keys(this._libraryIdMap).filter((function(t){return"pending"===e._libraryIdMap[t]})).map((function(t){return{id:t,progress:e._syncProgressMap[t]&&e._syncProgressMap[t].progress}}))}},{key:"startPolling",value:function(){var e=this;if(this._config.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"startPolling() not supported with shared local storage");this.isPolling||(this._pollTimerId=setInterval((function(){"never"!==e._retryTime&&(e._backoffTicks>0?e._backoffTicks--:(0===e._backoffTicks&&(e._numBackoffs++,e._backoffTicks=e._config.getBackoffTicks(e._numBackoffs)),e._syncWithParameters(!0)))}),this._pollInterval))}},{key:"stopPolling",value:function(){if(this._config.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"stopPolling() not supported with shared local storage");this.isPolling&&(clearInterval(this._pollTimerId),delete this._pollTimerId),this._retryTimeoutId&&(clearTimeout(this._retryTimeoutId),delete this._retryTimeoutId)}},{key:"getLibraryById",value:function(e){var t=this._libraryIdMap[e];if(t instanceof a)return t}},{key:"updateAccessToken",value:function(e){if(this._config.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"updateAccessToken() not supported with shared local storage");this._syncManager.updateAccessToken(e),this._services.log("defined")}},{key:"getTempDir",value:function(e){if(this._services.hasFileSystem()){var t=this._getTempDir();this._services.fileUtils.ensurePathExists(t,(function(n){return e(n,t)}))}else e(new c(c.REQUIRES_FILESYSTEM,"getTempDir only supported when you have a filesystem"))}},{key:"copyFileToTempDir",value:function(e,t){var n=this;this.getTempDir((function(i,o){if(i)t(i);else{var r=n._services.fileUtils.getFileExtension(e),a=o+n._services.getPathSeparator()+n._services.uuid()+(r?"."+r:"");n._services.fileUtils.copyFile(e,a,(function(e){e?n._services.fileUtils.deleteFile(a,(function(){return t(e)})):t(null,a)}))}}))}},{key:"_loadLibraryFromBookmark",value:function(e,t){var n=this,i=e.id,o=e.role,r=this.getLibraryById(i);if(r){var a="editor"===o;return!this.isPublic&&o&&a!==r._dcxComposite.isWritable&&(r._dcxComposite.isWritable=a,r._commit(!0,!0)),void t(null,r)}if(!e||this.canLoadLibrary(e)){var s=this._newLibrariesLoading[i];if(s)s.push(t);else{this._newLibrariesLoading[i]=[t];var l=function(e,t){var o=n._newLibrariesLoading[i];delete n._newLibrariesLoading[i],o.forEach((function(n){return n(e,t)}))};if(this._config.SHARED_LOCAL_STORAGE)throw new c(c.NOT_ALLOWED,"Library cannot be loaded from bookmark in shared-storage mode.");this._syncNewLibrary(i,e.url||e.urn,void 0,(function(e){if(e)l(e);else{var t=n.getLibraryById(i);t&&n.isPublic&&(t._dcxComposite.isWritable=!1,t._commit(!0,!0)),l(null,t)}})),e._onRemove=function(){n._newLibrariesLoading[i]&&(n._newLibrariesLoading[i].push((function(){n._services.fileUtils.deleteLibraryFromDisk(n,i,t)})),n._syncManager.abortPushOrPull(i))}}}else t(new c(c.INVALID_PARAMETER,"Invalid library location"))}},{key:"_unloadLibrary",value:function(e,t){var n=this._libraries.indexOf(e);if(-1!==n){if(this._libraries.splice(n,1),delete this._libraryIdMap[e.id],e._abortPushOrPull(),e._markDeletedLocally(!0),this._config.SHARED_LOCAL_STORAGE)return t(new c(c.NOT_ALLOWED,"Libraries cannot be unloaded in shared-storage mode."));e._deletedFromDisk=!0,this._services.fileUtils.deleteLibraryFromDisk(this,e.id,t),this._listenerManager.notify("change")}else t(null)}},{key:"_getLibrariesToUnload",value:function(){return[]}},{key:"_collectionManager",get:function(){return this._apiRoot._collectionManager}},{key:"_services",get:function(){return this._apiRoot._services}},{key:"_config",get:function(){return this._apiRoot._config}},{key:"_analytics",get:function(){return this._apiRoot._analytics}},{key:"_localisation",get:function(){return this._apiRoot._localisation}},{key:"_storageInterface",get:function(){return this._apiRoot._storageInterface}},{key:"_directoryName",get:function(){return this._cloudId}},{key:"platformFolders",get:function(){return this._platformManager.folders}},{key:"_href",get:function(){return this.isPrivate?r.appendPathElements(this._syncManager.getStorageHost(),this._config.STORAGE_ASSETS_PATH,this._config.LIBRARY_SYNC_GROUP):null}},{key:"libraries",get:function(){return this._libraries}},{key:"commitError",get:function(){return this._lastCommitError}},{key:"syncState",get:function(){return this._syncState}},{key:"syncErrors",get:function(){return this._syncErrors}},{key:"syncProgress",get:function(){return this._syncProgress}},{key:"supportsONSNotifications",get:function(){return!1}},{key:"isInitialSyncInProgress",get:function(){return this._initialSyncInProgress}},{key:"isPolling",get:function(){return void 0!==this._pollTimerId}},{key:"isPrivate",get:function(){return!this.isPublic&&!this.isCollaborated}},{key:"isLoggedIn",get:function(){if(!this._config.SHARED_LOCAL_STORAGE)return this._syncManager.isLoggedIn()}},{key:"retryTime",get:function(){return"never"!==this._retryTime?this._retryTime:void 0}},{key:"userId",get:function(){return this._userId}},{key:"userProfile",get:function(){return this._userProfile}},{key:"cloudId",get:function(){return this._cloudId}},{key:"operations",get:function(){return this._operations}},{key:"_pollInterval",get:function(){return 6e4*this._config.POLL_INTERVAL}}])&&i(t.prototype,n),e}();e.exports=g},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(1),r=n(6),a=n(7),s=function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._listenerManager=new a(["change"],(function(e){return t._services.log(e)}))}var t,n;return t=e,(n=[{key:"_getRawName",value:function(){return this._dcxNode.name||""}},{key:"_getName",value:function(){var e=this._localisation.getLocale();return e&&this.getLocalizedName(e)||this._getRawName()}},{key:"_setName",value:function(e){this._dcxNode.name=e,this._dcxNode.removeValue(this._config.LOCALIZED_NAME_KEY),this._dcxNode.removeValue(this._config.AUTO_NAMED_KEY)}},{key:"_markDeletedLocally",value:function(e){this._deletedLocally=e,e&&this._listenerManager.removeAll()}},{key:"_removeAllListeners",value:function(){this._listenerManager.removeAll()}},{key:"toString",value:function(){return JSON.stringify(this._toJSON())}},{key:"jasmineToString",value:function(){return this.toString()}},{key:"_constructActions",value:function(e,t,n,i){var o=this,r=[];t.forEach((function(t){!n.products[t]||e&&e!==n.products[t].action||r.push(new i(o,n.products[t]))}));var a=r.map((function(e,t){return{i:t,v:e}}));return a.sort((function(e,t){return e.v.isCompatibleVersionInstalled&&!t.v.isCompatibleVersionInstalled?-1:t.v.isCompatibleVersionInstalled&&!e.v.isCompatibleVersionInstalled?1:e.i-t.i})),a.map((function(e){return e.v}))}},{key:"getLocalizedName",value:function(e){return this.getLocalizedNames()[e]||""}},{key:"getLocalizedNames",value:function(){return this._dcxNode.getValue(this._config.LOCALIZED_NAME_KEY)||{}}},{key:"setLocalizedName",value:function(e,t){if(r.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this._libraryId);var n=this.getLocalizedNames();n[e]=t,this._dcxNode.setValue(this._config.LOCALIZED_NAME_KEY,n),this._commitMetadata()}},{key:"addChangeListener",value:function(e){r.checkDeletedState(this),this._listenerManager.add("change",e)}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e)}},{key:"_libraryId",get:function(){return this.library?this.library.id:this.id}},{key:"name",get:function(){return this._getName()},set:function(e){if(r.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this._libraryId);this._setName(e),this._updateName&&this._updateName(),this._commitMetadata(),this._reportRename&&this._reportRename()}},{key:"created",get:function(){return this._dcxNode.getValue(this._config.CREATED_KEY)}},{key:"modified",get:function(){return this._dcxNode.getValue(this._config.MODIFIED_KEY)}},{key:"isDeletedLocally",get:function(){return this._deletedLocally}}])&&i(t.prototype,n),e}();e.exports=s},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var c=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=r(this,a(t).call(this)))._library=e,n}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,e),n=t,(i=[{key:"_getEventData",value:function(e,t){var n=!t&&{},i=this._dcxNode.getValue(this._config[e+"_DATA_KEY"])||n;if("CREATED"!==e&&"DESCRIPTION"!==e){var o=this._dcxNode.getValue(this._config[e+"_KEY"]);if(!o||o!==i.time)return n}return i}},{key:"_setEventData",value:function(e,t){if(this._config.DEVICE_ID){var n={userId:this.library.collection.userId,deviceId:this._config.DEVICE_ID};this._config.DEVICE_DESCRIPTION&&(n.device=this._config.DEVICE_DESCRIPTION),this._config.APP_DESCRIPTION&&(n.app=this._config.APP_DESCRIPTION),t&&(n.time=t),this._dcxNode.setValue(this._config[e+"_DATA_KEY"],n)}else this._clearEventData(e)}},{key:"_clearEventData",value:function(e){this._dcxNode.getValue(this._config[e+"_DATA_KEY"])&&this._dcxNode.removeValue(this._config[e+"_DATA_KEY"])}},{key:"_isLocalEvent",value:function(e){var t=this._getEventData(e).deviceId;if(t&&this._config.DEVICE_ID)return t===this._config.DEVICE_ID}},{key:"_getEventContext",value:function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.time,delete t.deviceId,delete t.userId,t}},{key:"_commit",value:function(){this._updateModifiedTime(),this._listenerManager.notify("change"),this._library._commit()}},{key:"_commitMetadata",value:function(){this._listenerManager.notify("change"),this._library._commit()}},{key:"_updateCreatedTime",value:function(){var e=Date.now();this._dcxNode.setValue(this._config.CREATED_KEY,e),this._dcxNode.setValue(this._config.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED",e)}},{key:"_updateModifiedTime",value:function(){var e=Date.now();this._dcxNode.setValue(this._config.MODIFIED_KEY,e),this._setEventData("MODIFIED",e)}},{key:"_ensureModifiedDataValid",value:function(e){this._getEventData("MODIFIED",!0)||(e?this._setEventData("MODIFIED",this.modified):this._clearEventData("MODIFIED")),this._ensureRemovedDataValid(e)}},{key:"_ensureCreatedDataValid",value:function(e){e&&!this._getEventData("CREATED",!0)&&this._setEventData("CREATED"),this._ensureModifiedDataValid(e)}},{key:"touch",value:function(){this._commit()}},{key:"_config",get:function(){return this._library._config}},{key:"_services",get:function(){return this._library._services}},{key:"_analytics",get:function(){return this._library._analytics}},{key:"_localisation",get:function(){return this._library._localisation}},{key:"id",get:function(){return this._dcxNode.id}},{key:"library",get:function(){return this._library}},{key:"isWritable",get:function(){return this._library.isWritable}},{key:"createdBy",get:function(){return this._getEventData("CREATED").userId}},{key:"createdContext",get:function(){return this._getEventContext("CREATED")}},{key:"wasCreatedLocally",get:function(){return this._isLocalEvent("CREATED")}},{key:"modifiedBy",get:function(){return this._getEventData("MODIFIED").userId}},{key:"modifiedContext",get:function(){return this._getEventContext("MODIFIED")}},{key:"wasModifiedLocally",get:function(){return this._isLocalEvent("MODIFIED")}}])&&o(n.prototype,i),t}(n(32));e.exports=c},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(1),r=n(4),a=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._item=t,this._id=n.action,this._appCode=n.appCode,this._appName=n.appName,this._minVersion=n.minVersion,this._installedVersions=this._config.ELEMENT_ACTION_PRODUCT_MAP.installedApps.filter((function(e){return e.code===n.appCode})).map((function(e){return e.version})).sort(r.compareVersions),this._invokable=this._installedVersions.length>0&&r.compareVersions(n.minVersion,this._installedVersions[0])>=0,Object.freeze(this._installedVersions)}var t,n;return t=e,(n=[{key:"invoke",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this.isCompatibleVersionInstalled?(this._analytics.reportActionInvoked(this),this._storageInterface.sendAction(this,(function(n,i){n?(n=-1!==["APP_NOT_INSTALLED","NO_COMPATIBLE_VERSION"].indexOf(n)?new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action:"+n):new o(o.APP_LAUNCH_FAILED,"Launching the app failed:"+n),e._analytics.reportActionFailed(e,n)):e._analytics.reportActionSuccessful(e,i),t(n,i)}))):t(new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action",this._appCode))}},{key:"_config",get:function(){return this._item._config}},{key:"_analytics",get:function(){return this._item._analytics}},{key:"_storageInterface",get:function(){return this._item._storageInterface}},{key:"appCode",get:function(){return this._appCode}},{key:"appName",get:function(){return this._appName}},{key:"minAppVersion",get:function(){return this._minVersion}},{key:"installedVersions",get:function(){return this._installedVersions}},{key:"isCompatibleVersionInstalled",get:function(){return!!this._invokable}}])&&i(t.prototype,n),e}();e.exports=a},function(e,t){var n={},i={"application/x-indesign":!0,"application/postscript":!0,"application/illustrator":!0,"application/pdf":!0,"application/vnd.adobe.psremix":!0,"application/vnd.adobe.pstouch":!0,"application/vnd.adobe.ideas":!0,"application/vnd.adobe.ase":!0,"image/jpeg":!0,"image/jpg":!0,"image/pjpeg":!0,"image/tiff":!0,"image/gif":!0,"image/bmp":!0,"image/x-ms-bmp":!0,"image/svg+xml":!0,"image/png":!0,"image/x-png":!0,"image/jp2":!0,"image/psd":!0,"image/vnd.adobe.photoshop":!0,"image/heic":!0,"application/photoshop":!0,"application/x-photoshop":!0,"image/raw":!0,"image/dng":!0,"image/x-adobe-dng":!0,"video/mp4":!0,"video/mpeg":!0,"video/x-ms-wmv":!0,"video/3gpp":!0,"video/3gpp2":!0,"video/quicktime":!0,"video/x-msvideo":!0,"video/x-flv":!0,"video/x-ms-asf":!0,"video/x-m4v":!0,"video/mp2t":!0,"application/mxf":!0,"application/x-shockwave-flash":!0,"application/vnd.adobe.brushes.brush+ucf":!0,"application/vnd.adobe.collage":!0,"application/vnd.adobe.proto":!0,"application/msword":!0,"application/msexcel":!0,"application/mspowerpoint":!0,"application/vnd.ms-publisher":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":!0,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":!0,"application/vnd.openxmlformats-officedocument.presentationml.presentation":!0,"text/plain":!0,"text/rtf":!0};n.canComputeRenditionFromMimeType=function(e){return!!i[e]},n.canComputeRendition=function(e){return!(void 0===e._dcxComponent||!n.canComputeRenditionFromMimeType(e.type))},Object.seal(n),e.exports=n},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var r=n(70),a=n(71),s=n(9),c=n(3),l=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._apiRoot=t,this._rootDir=n,this._cache={},this._pendingCacheItems={},this._lock=new s,this._fs=r(this._services.fs,this._services.fileUtils),this._path=a(this._services.getPathSeparator())}var t,n;return t=e,(n=[{key:"load",value:function(){var e=this;return this._loadingPromise||(this._loadingPromise=this._doTransaction((function(){return e._load()}),!1)),this._loadingPromise}},{key:"save",value:function(){var e=this;return this._doTransaction((function(){return e._save()}))}},{key:"_doTransaction",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=function(){return t._lock.release()},o=new Promise((function(e){return t._lock.obtain(e)})).then(e);return n&&(o=o.then((function(e){return t._save().then((function(){return e}))}))),o.then(i,i),o}},{key:"_load",value:function(){var e=this;return!this._services.hasFileSystem()||this._config.SHARED_LOCAL_STORAGE?Promise.resolve():this._services.fileUtils.readJSONData(this._path.join(this._rootDir,this._config.RENDITION_CACHE_FILE)).catch((function(){})).then((function(t){e._cache=t||{}}))}},{key:"_save",value:function(){var e=this;return!this._services.hasFileSystem()||this._config.SHARED_LOCAL_STORAGE?Promise.resolve():this._services.fileUtils.writeJSONData(this._rootDir,this._config.RENDITION_CACHE_FILE,this._cache).then((function(){return e._gcUnreferencedFiles()}))}},{key:"_waitForCommit",value:function(e){if(!this._lock.isLocked())return e();this._doTransaction(e,!1)}},{key:"_getCache",value:function(e){for(var t=this._cache,n=0;t&&n<e.length;n++)t=t[e[n]];return t}},{key:"_isErrorCode",value:function(e){return e&&c.isErrorCode(e)}},{key:"_isPath",value:function(e){return e&&e!==this._config.RENDITION_CACHE_PLACEHOLDER&&!this._isErrorCode(e)}},{key:"_getFilePath",value:function(e,t){if(e){if(t&&!this._isPath(e))return e;var n=this._path.join(this._rootDir,e);return this._config.SHARED_LOCAL_STORAGE||this._fs.statSync(n)?n:void 0}}},{key:"_setCacheEntry",value:function(e,t){for(var n=this._cache,i=0;i<e.length-1;i++){var o=e[i];n=n[o]=n[o]||{}}var r=e[e.length-1];return void 0===t?delete n[r]:n[r]=t,t}},{key:"_setCache",value:function(e,t,n){var i=this,o=this._services.fileUtils.getFileExtension(t)||"png",r="".concat(this._services.uuid(),".").concat(o);return this._fs.ensureDir(this._rootDir).then((function(){i._pendingCacheItems[r]=!0;var e=n?"rename":"copy";return i._fs[e](t,i._path.join(i._rootDir,r))})).then((function(){return delete i._pendingCacheItems[r],i._setCacheEntry(e,r),i._path.join(i._rootDir,r)})).catch((function(e){return delete i._pendingCacheItems[r],Promise.reject(c.getCommitError(e,void 0,"unable to save cache to disk"))}))}},{key:"_iterate",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._cache,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];Object.keys(n).forEach((function(r){"object"===i(n[r])?t._iterate(e,n[r],o.concat(r)):e(o,n[r])}))}},{key:"_gcUnreferencedFiles",value:function(){var e=this,t={};return this._iterate((function(n,i){t[i]=!0,delete e._pendingCacheItems[i]})),this._fs.readdir(this._rootDir).then((function(n){var i=[];return n.forEach((function(n){var o=e._services.fileUtils.normaliseTempFileName(n);n===e._config.RENDITION_CACHE_FILE||t[n]||e._pendingCacheItems[o]||i.push(e._fs.remove(e._path.join(e._rootDir,n)))})),Promise.all(i)}))}},{key:"_config",get:function(){return this._apiRoot._config}},{key:"_services",get:function(){return this._apiRoot._services}},{key:"_storageInterface",get:function(){return this._apiRoot._storageInterface}}])&&o(t.prototype,n),e}();e.exports=l},function(e,t){function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var r=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._type=t,this._id=n}var t,r;return t=e,(r=[{key:"toJSON",value:function(e){return function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){i(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({type:this._type,id:this._id},e)}},{key:"toString",value:function(){return JSON.stringify(this.toJSON())}},{key:"isReferenceTo",value:function(){return!1}},{key:"id",get:function(){return this._id}},{key:"type",get:function(){return this._type}}])&&o(t.prototype,r),e}();e.exports=r},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(9),r=n(7),a=n(3),s=n(1),c=function(){function e(t,n){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._fileName=t,this._collection=n,this._lock=new o,this._listenerManager=new r(["change"],(function(e){return i._services.log(e)}))}var t,n;return t=e,(n=[{key:"_getBaseDir",value:function(){return this._collection._getBaseDir()}},{key:"_toJSON",value:function(){throw new s(s.NOT_IMPLEMENTED,"_toJSON must be defined by child class.")}},{key:"_fromJSON",value:function(){throw new s(s.NOT_IMPLEMENTED,"_fromJSON must be defined by child class.")}},{key:"_load",value:function(){var e=this;if(!this._services.hasFileSystem())return Promise.resolve();this._services.log("Loading from disk: ".concat(this._fileName));var t=this._getBaseDir()+this._services.getPathSeparator()+this._fileName;return this._services.fileUtils.readJSONData(t).then((function(t){return e._fromJSON(t)})).catch((function(t){e._collection._reportCommitError(a.getCommitError(t,null,"data could not be loaded from disk"))}))}},{key:"_save",value:function(){var e=this;return this._services.hasFileSystem()?(this._services.log("Saving to disk: ".concat(this._fileName)),this._services.fileUtils.writeJSONData(this._getBaseDir(),this._fileName,this._toJSON()).catch((function(t){e._collection._reportCommitError(a.getCommitError(t,null,"serialized data could not be saved"))}))):Promise.resolve()}},{key:"load",value:function(){var e=this;return this._lock.execute((function(){return e._load()}))}},{key:"save",value:function(){var e=this;return this._lock.execute((function(){return e._save()}))}},{key:"addChangeListener",value:function(e){this._listenerManager.add("change",e)}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e)}},{key:"_services",get:function(){return this._collection._services}},{key:"_storageInterface",get:function(){return this._collection._storageInterface}},{key:"_config",get:function(){return this._collection._config}},{key:"_syncManager",get:function(){return this._collection._syncManager}}])&&i(t.prototype,n),e}();e.exports=c},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=t.id,this._name=t.name,this._links=t.links,this._permissions=t.permissions,this._ownerType=t.ownerType,this._ownerId=t.ownerId,this._ownerName=t.ownerName,this._createdBy=t.createdBy}var t,i;return t=e,(i=[{key:"toJSON",value:function(){return{id:this.id,name:this.name,links:this.links,permissions:this.permissions,ownerType:this.ownerType,ownerId:this.ownerId,ownerName:this.ownerName,createdBy:this.createdBy}}},{key:"id",get:function(){return this._id}},{key:"name",get:function(){return this._name}},{key:"links",get:function(){return this._links}},{key:"isWritable",get:function(){return this._permissions&&this._permissions.includes("write")}},{key:"ownerId",get:function(){return this._ownerId}},{key:"ownerType",get:function(){return this._ownerType}},{key:"ownerName",get:function(){return this._ownerName}},{key:"createdBy",get:function(){return this._createdBy}},{key:"permissions",get:function(){return this._permissions}}])&&n(t.prototype,i),e}();e.exports=i},function(e,n,i){function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r=i(28),a=i(3),s=i(1),c={},l=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\.[^/\\]+$/i;c.importLibrary=function(e,t,n,i){var o,l,u=e._services.fileUtils,h=function(t,n){if(l&&(t=new s(s.OPERATION_CANCELLED,"import cancelled")),t)i(t);else{o=void 0;var r=n.libraryId,c=n.extractPath,h=e._getCompositeDir(r),p=function(e){u.recursiveDeleteDirectory(c),u.recursiveDeleteDirectory(h),i(e)};u.rename(c,h,(function(t){if(t)return p(a.getFileSystemError(t,"unable to move extracted zip after import"));e._loadLibrary(r,(function(t){if(t)return p(t);var n=e.getLibraryById(r);if(!n)return p(new s(s.INVALID_DATA,"could not load library after import"));e._notifyChange(!0),n._push(),i(null,n)}))}))}};return r.isSnapshot(t,(function(i,s){if(i||l)h(i&&a.getSnapshotError(i,void 0,"error opening library archive"));else{var u=e._getTempDir();o=s?r.importSnapshot(t,u,(function(t){return e._getNewCompositeHref(t)}),!1,n,(function(e,t){!e&&t?h(null,{libraryId:t.id,extractPath:t.path}):h(a.getSnapshotError(e,void 0,"cannot import the snapshot file"))})):c._importNonSnapshotLibrary(e,t,u,n,h)}})),function(){l||(l=!0,o&&o())}},c._importNonSnapshotLibrary=function(e,n,i,r,c){var u=e._services.fileUtils,h=e._services.getPathSeparator(),p=e._services.fs,d=e._services.yauzl;if(d){var _,f=e._services.uuid(),m=i+e._services.getPathSeparator()+f,v=e._getNewCompositeHref(f),y=!1,g=-1,E=0,O=0,A=!1,S=function(e){A||(A=!0,e&&u.recursiveDeleteDirectory(m),c(e,e?void 0:{libraryId:f,extractPath:m}))},b=m+h+"components";return u.ensurePathExists(b,(function(i){i?S(a.getFileSystemError(i,"unable to create temp dir")):d.open(n,{lazyEntries:!0},(function(n,i){n?-1!==["EPERM","EACCES","ENOENT"].indexOf(n.code)?S(a.getFileSystemError(n,"error opening library archive")):S(new s(s.INVALID_DATA,"error opening library archive: "+n)):((_=i).on("entry",(function(n){g++,E=0,O=0,function(e){return"data"===e.fileName||e.fileName.match(l)}(n)?"data"!==n.fileName?(E=n.uncompressedSize,_.openReadStream(n,(function(e,t){e?S(a.getFileSystemError(e,"error extracting zip file")):(t.on("end",(function(){_.readEntry()})),t.on("data",(function(e){O+=e.length,function(){if(!y){var e=g/_.entryCount;E&&(e+=O/(E*_.entryCount)),r(Math.round(100*e))}}()})).on("error",(function(e){S(a.getFileSystemError(e,"error extracting zip file"))})).pipe(p.createWriteStream(b+h+n.fileName)))}))):_.openReadStream(n,(function(n,i){if(n)S(a.getFileSystemError(n,"error reading zip file entry"));else{var r=[];i.on("data",(function(e){r.push(e)})),i.on("error",(function(e){S(a.getFileSystemError(e,"error extracting zip file"))})),i.on("end",(function(){var n=function(e,t,n,i){var r;try{r=JSON.parse(e)}catch(e){return null}if(!r||r.version!==i)return null;var a=r.manifest,s=r.componentMap;return"object"!==o(s)||Object.keys(s).some((function(e){return"string"!=typeof s[e]}))?null:(a.id=t,a.local={version:2,change:1,compositeHref:n,"copyOnWrite#storageIds":r.componentMap},{json:r,manifest:a})}(t.concat(r).toString(),f,v,e._config.EXPORT_VERSION);n&&n.manifest?p.writeFile(m+h+"manifest",JSON.stringify(n.manifest,void 0,2),(function(e){e?S(a.getFileSystemError(e,"unable to write manifest file")):_.readEntry()})):S(new s(s.INVALID_DATA,"unable to parse export data"))}))}})):_.readEntry()})).on("error",(function(e){S(a.getFileSystemError(e,"error extracting zip file"))})).on("close",(function(){y?S(new s(s.OPERATION_CANCELLED,"import cancelled")):S()})),_.readEntry())}))})),function(){y||(y=!0,_&&_.close())}}c(new s(s.NOT_SUPPORTED,"yauzl (unzip) module not present"))},c.exportLibrary=function(e,t,n,i){var o,c=r.exportSnapshot(e._dcxComposite,t,(function(t){return delete t["".concat(e._config.TOOLKIT_NAMESPACE,"#").concat(e._config.TOOLKIT_ID_KEY)],delete t[e._config.DOCUMENT_ID_KEY],delete t[e._config.DOCUMENT_TYPE_KEY],t.children=t.children.filter((function(t){return t.name!==e._config.REMOVED_ELEMENTS_NAME})),t}),n,(function(t){i(o?new s(s.OPERATION_CANCELLED,"export cancelled"):t&&a.getSnapshotError(t,e.id,"cannot export a snapshot file"))}));return function(){o||(o=!0,c())}},Object.seal(c),e.exports=c},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e,t,n){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=n(84),h=n(18),p=function(e){function t(){return o(this,t),a(this,c(t).apply(this,arguments))}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(t,e),n=t,(i=[{key:"createLibrary",value:function(e,n){var i=s(c(t.prototype),"createLibrary",this).call(this,e,n),o=h.waitForPushNew(i.id);return this._bookmarkManager.createBookmark("collab",i.id,{},o),i}},{key:"removeLibrary",value:function(e,n){s(c(t.prototype),"removeLibrary",this).call(this,e,n);var i=this._bookmarkManager.findBookmark(e);if(i){var o=h.waitForDelete(e.id);this._bookmarkManager.removeBookmark(i,o)}}},{key:"canLoadLibrary",value:function(e){return e.urn&&!e.url}},{key:"loadLibrary",value:function(e,t){return this._loadLibraryFromBookmark(e,t)}},{key:"isCollaborated",get:function(){return!0}}])&&r(n.prototype,i),t}(u);e.exports=p},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,o)}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){function t(e,n,i){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n.IS_PUBLIC=!0,n.USER_ID=n.USER_ID||e._config.PUBLIC_USER_ID,a(this,s(t).call(this,e,n,i))}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"_dosync",value:function(e,t){var n=this;this._clearSyncErrors();var i=this._libraries.map(function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._dcxComposite.isWritable&&(t._dcxComposite.isWritable=!1,t._commit(!0,!0)),t._dcxComposite.assetId){e.next=12;break}return e.prev=2,e.next=5,n._syncManager.getPublicLibraryAssetId(t);case 5:i=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(2),n._services.log("Unable to get assetId for ".concat(t.id,". Error: ").concat(e.t0));case 11:i&&(t._dcxComposite.assetId=i,t._commit(!0,!0));case 12:return e.abrupt("return",n._doSyncLibrary(t));case 13:case"end":return e.stop()}}),e,null,[[2,8]])})),function(){var t=this,n=arguments;return new Promise((function(i,r){var a=e.apply(t,n);function s(e){o(a,i,r,s,c,"next",e)}function c(e){o(a,i,r,s,c,"throw",e)}s(void 0)}))});return function(e){return t.apply(this,arguments)}}());Promise.all(i).then((function(e){return t(null,e.some((function(e){return e})))}))}},{key:"_doSyncLibrary",value:function(e){var t=this;return new Promise((function(n){t._syncManager.hasCompositeChangedOnServer(e._dcxComposite,(function(i){e._sync(!i,(function(e,i){e&&t._reportSyncError(e),n(i)}))}))}))}},{key:"canLoadLibrary",value:function(e){var t=e.url;return new RegExp("".concat(this._syncManager.getStorageHost(),"/(.+)")).test(t)}},{key:"loadLibrary",value:function(e,t){return this._loadLibraryFromBookmark(e,t)}},{key:"unloadLibrary",value:function(e,t){return this._unloadLibrary(e,t)}},{key:"_getLibrariesToUnload",value:function(){var e=this;return this.libraries.filter((function(t){return!e._bookmarkManager.findBookmark(t)}))}},{key:"isPublic",get:function(){return!0}}])&&r(n.prototype,i),t}(n(31));e.exports=l},function(e,t,n){function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],i=!0,o=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){o=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(o)throw r}}return n}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var c=n(44),l=n(16),u=n(62),h=n(29),p=n(41),d=n(42),_=n(85),f=n(1),m=n(86),v=n(111),y=n(115),g=n(116),E=n(10),O=n(35),A=n(6),S=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),b=function(){function e(t,n){var i=this;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._config=new l,this._services=new c(this._config),this._services.hasFileSystem()||void 0!==n.SHARED_LOCAL_STORAGE||(n.SHARED_LOCAL_STORAGE=!1),this._services.hasFileSystem()&&!n.ROOT_DIR&&!1===n.SHARED_LOCAL_STORAGE)throw new f(f.INVALID_PARAMETER,"Missing ROOT_DIR option");if(this._services.hasFileSystem()&&n.ROOT_DIR&&!1!==n.SHARED_LOCAL_STORAGE)throw new f(f.INVALID_PARAMETER,"ROOT_DIR option doesn't apply when using shared local storage");if(!this._services.hasFileSystem()&&n.ROOT_DIR)throw new f(f.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");if(!1===n.SHARED_LOCAL_STORAGE&&!n.STORAGE_API_KEY)throw new f(f.INVALID_PARAMETER,"Missing STORAGE_API_KEY option");if(!1===n.SHARED_LOCAL_STORAGE&&!n.DEVICE_ID)throw new f(f.INVALID_PARAMETER,"Missing DEVICE_ID option");if(!1!==n.SHARED_LOCAL_STORAGE&&!this._services.hasCEPVulcan()&&!t.vulcanCall)throw new f(f.INVALID_PARAMETER,"Shared local storage requires either the CEP VulcanInterface/VulcanMessage as globals, or for you to pass in the vulcanCall dependency");if(!n.APP_DESCRIPTION)throw new f(f.INVALID_PARAMETER,'Missing APP_DESCRIPTION option - should be a string of the form <name>-<version>, e.g. "PHXS-16.0".');if(n.ROOT_DIR)for(;-1!==["/","\\"].indexOf(n.ROOT_DIR.substr(-1));)n.ROOT_DIR=n.ROOT_DIR.slice(0,-1);this._services.vulcanCall=t.vulcanCall,this._services._log=t.log,this._services._getNodeTunnelOptions=t.getNodeTunnelOptions,this._services._getOrgBetaStatus=t.getOrgBetaStatus,t.renditionGenerator&&this._services.setRenditionGenerator(t.renditionGenerator),this._analytics=new u(t.analytics,this._config),this._storageInterface=new v(this,{onConnected:t.onClientConnected}),this._externalUtils=new y(this),this._externalAnalyticsUtils=new g(this),this._localisation=new m(this,n.LOCALE),delete n.LOCALE,Object.keys(n).forEach((function(e){return i._config.setParameter(e,n[e])})),this._collectionManager=new _(this),this._loadingState={},this._services.log("Configure: "+(this._config.SHARED_LOCAL_STORAGE?"<shared local storage>":this._config.ROOT_DIR))}var t,n,o;return t=e,o=[{key:"getSNISettings",value:function(){var e=new l;return{TLS_DISCOVERY_PORT_RANGE:e.TLS_DISCOVERY_PORT_RANGE,TLS_DELAY_ON_DECLINE:2*e.TLS_DELAY_ON_DECLINE,TLS_DELAY_ON_READY:2*e.TLS_DELAY_ON_READY}}},{key:"mimeTypeToExtensions",value:function(e){return E.getExtensions(e)}},{key:"extensionToMimeTypes",value:function(e){return E.getMimeTypes(e)}},{key:"canGenerateRenditionFromMimeType",value:function(e){return O.canComputeRenditionFromMimeType(e)}},{key:"errors",get:function(){return f}}],(n=[{key:"_addLoadCallback",value:function(e,t,n){var i=e+"/"+t,o=void 0!==this._loadingState[i];return this._loadingState[i]=this._loadingState[i]||[],this._loadingState[i].push(n),o}},{key:"_notifyLoadCallbacks",value:function(e,t){var n;n=e===this._config.PUBLIC_USER_ID?this._collectionManager.getPublicLibraryCollection(t):t===this._config.COLLABORATED_CLOUD_ID?this._collectionManager.getCollaboratedLibraryCollection(e):this._collectionManager.getLibraryCollection(e,t);var i=e+"/"+t,o=this._loadingState[i];o&&(delete this._loadingState[i],o.forEach((function(e){return e(null,n)})))}},{key:"_getPrivateCollection",value:function(e){return this._collectionManager.getLoadedCollections().find((function(t){return t.isPrivate&&t.userId===e}))}},{key:"setOption",value:function(e,t){if(-1!==["ROOT_DIR","SHARED_LOCAL_STORAGE","ELEMENT_TYPE_FILTERS","STORAGE_API_KEY"].indexOf(e))throw new f(f.INVALID_PARAMETER,"Cannot reconfigure "+e);this._config.setParameter(e,t),this._storageInterface.updateConfiguration()}},{key:"getOption",value:function(e){return this._config[e]}},{key:"setLocalSetting",value:function(e,t){if("string"!=typeof e)throw new f(f.INVALID_PARAMETER,"Key must be a string");try{JSON.stringify(t)}catch(e){throw new f(f.INVALID_PARAMETER,"Value must be serializable to JSON")}this._config.setLocalSetting(e,t),this._storageInterface.updateConfiguration()}},{key:"getLocalSetting",value:function(e){return this._config.LOCAL_SETTINGS[e]}},{key:"addConfigurationChangeListener",value:function(e){this._config.addChangeListener(e)}},{key:"removeConfigurationChangeListener",value:function(e){this._config.removeChangeListener(e)}},{key:"getLoadedCollections",value:function(){return this._collectionManager.getLoadedCollections().slice(0)}},{key:"getLoadedCollectionById",value:function(e,t){return this._collectionManager.getLibraryCollection(e,t)}},{key:"getLoadedPublicCollectionById",value:function(e){return this._collectionManager.getPublicLibraryCollection(e)}},{key:"getLoadedCollaboratedCollectionById",value:function(e){return this._collectionManager.getCollaboratedLibraryCollection(e)}},{key:"addLoadedCollectionsListener",value:function(e){this._collectionManager.addLoadedCollectionsListener(e)}},{key:"removeLoadedCollectionsListener",value:function(e){this._collectionManager.removeLoadedCollectionsListener(e)}},{key:"getRootDir",value:function(){if(!this._services.hasFileSystem())throw new f(f.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");return this._config.ROOT_DIR}},{key:"refreshPlatformFolders",value:function(e){this.getLoadedCollections().find((function(e){return e.isPrivate}))._platformManager.refreshPlatformFolders(e)}},{key:"_getCachedRootDocument",value:function(){return this.getLoadedCollections().find((function(e){return e.isPrivate}))._platformManager.cachedRootDocument}},{key:"getLocale",value:function(){return this._localisation.getLocale()}},{key:"unloadLibraryCollection",value:function(e){if(this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"unloadLibraryCollection() not supported with shared local storage");e.stopPolling(),e._removeAllListeners(),e._abortPushOrPull(!0),this._collectionManager.removeLibraryCollection(e)}},{key:"loadLibraryCollection",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if("function"!=typeof t)if(this._config.SHARED_LOCAL_STORAGE)n(new f(f.NOT_SUPPORTED,"loadLibraryCollection() not supported with shared local storage"));else{t.CLOUD_ID=t.CLOUD_ID||this._config.DEFAULT_CLOUD_ID;var i=["STORAGE_HOSTNAME","CC_LIBRARY_SERVICE_HOSTNAME","CC_IMAGE_HOSTNAME","CC_IMAGE_X_HOSTNAME","TYPEKIT_HOSTNAME"];this._services.hasFileSystem()&&i.unshift("USER_ID");for(var o=0;o<i.length;o++){var r=i[o];if(!t[r])return void n(new f(f.INVALID_PARAMETER,"Missing ".concat(r," option")))}var a=this._collectionManager.getLibraryCollection(t.USER_ID,t.CLOUD_ID),s=this._addLoadCallback(t.USER_ID,t.CLOUD_ID,n);if(!a||s){if(!s){a=new h(this,t);var c=function(){e._collectionManager.addLibraryCollection(a),e._config.AUTO_START_POLLING&&a.startPolling(),e._notifyLoadCallbacks(t.USER_ID,t.CLOUD_ID)};if(this._services.hasFileSystem())this._services.fileUtils.doesRootDirExist(a,(function(e,t){a._load((function(){t||a._setInitialSyncState(!0),a.sync((function(){return a._setInitialSyncState(!1)})),c()}))}));else if("all"===t.WAIT_FOR)a._setInitialSyncState(!0),a.sync((function(){a._setInitialSyncState(!1),c()}));else if(A.validateLibraryId(t.WAIT_FOR,!1)){a._setInitialSyncState(!0,[t.WAIT_FOR]),a.sync((function(){return a._setInitialSyncState(!1)}));var l=function e(){"syncing"===a.syncState&&"pending"===a._libraryIdMap[t.WAIT_FOR]||(a.removeChangeListener(e),a.removeSyncListener(e),c())};a.addChangeListener(l),a.addSyncListener(l)}else a._setInitialSyncState(!0),a.sync((function(){return a._setInitialSyncState(!1)})),c()}}else this._notifyLoadCallbacks(t.USER_ID,t.CLOUD_ID)}else(n=t)(new f(f.INVALID_PARAMETER,"options argument not specified"))}},{key:"loadPublicLibraryCollection",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if("function"!=typeof t)if(this._config.SHARED_LOCAL_STORAGE)n(new f(f.NOT_SUPPORTED,"loadPublicLibraryCollection() not supported with shared local storage"));else if(t.CLOUD_ID=t.CLOUD_ID||this._config.DEFAULT_CLOUD_ID,t.STORAGE_HOSTNAME){var i=this._collectionManager.getPublicLibraryCollection(t.CLOUD_ID),o=this._addLoadCallback(this._config.PUBLIC_USER_ID,t.CLOUD_ID,n);if(!i||o){if(!o){var r=this._getPrivateCollection(t.USER_ID);i=new d(this,t,r);var a=function(){e._collectionManager.addLibraryCollection(i),e._config.AUTO_START_POLLING&&i.startPolling(),e._notifyLoadCallbacks(e._config.PUBLIC_USER_ID,t.CLOUD_ID)};this._services.hasFileSystem()?i._load((function(){i.sync(),a()})):a()}}else this._notifyLoadCallbacks(this._config.PUBLIC_USER_ID,t.CLOUD_ID)}else n(new f(f.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));else(n=t)(new f(f.INVALID_PARAMETER,"options argument not specified"))}},{key:"loadCollaboratedLibraryCollection",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if("function"!=typeof t)if(this._config.SHARED_LOCAL_STORAGE)n(new f(f.NOT_SUPPORTED,"loadCollaboratedLibraryCollection() not supported with shared local storage"));else if(t.STORAGE_HOSTNAME){var i=this._collectionManager.getCollaboratedLibraryCollection(t.USER_ID),o=this._addLoadCallback(t.USER_ID,this._config.COLLABORATED_CLOUD_ID,n);if(!i||o){if(!o){var a=this._getPrivateCollection(t.USER_ID);i=new p(this,r({},t,{CLOUD_ID:this._config.COLLABORATED_CLOUD_ID}),a);var s=function(){e._collectionManager.addLibraryCollection(i),e._notifyLoadCallbacks(t.USER_ID,e._config.COLLABORATED_CLOUD_ID)};this._services.hasFileSystem()?i._load((function(){i.sync(),s()})):s()}}else this._notifyLoadCallbacks(t.USER_ID,this._config.COLLABORATED_CLOUD_ID)}else n(new f(f.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));else(n=t)(new f(f.INVALID_PARAMETER,"options argument not specified"))}},{key:"isConnected",value:function(){if(!this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"isConnected() is only applicable if using shared local storage");return this._storageInterface&&this._storageInterface.isConnected()}},{key:"reconnect",value:function(){if(!this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"reconnect() is only applicable if using shared local storage");this._storageInterface&&this._storageInterface.reconnect()}},{key:"disconnect",value:function(){if(!this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"disconnect() is only applicable if using shared local storage");this._storageInterface&&this._storageInterface.isConnected()&&this._storageInterface.shutdown()}},{key:"getServiceInfo",value:function(){if(!this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"getServiceInfo() is only applicable if using shared local storage");return this._storageInterface&&this._storageInterface.getServiceInfo()}},{key:"isSyncingEnabled",value:function(){if(this._config.SHARED_LOCAL_STORAGE){var e=this.getServiceInfo();return Boolean(e&&e.syncingEnabled)}return this._config.SYNCING_ENABLED}},{key:"enableSyncing",value:function(){this._config.SHARED_LOCAL_STORAGE?this._storageInterface.setSyncEnabled(!0):(this._config.SYNCING_ENABLED=!0,this.getLoadedCollections().forEach((function(e){return e.sync()})))}},{key:"disableSyncing",value:function(){this._config.SHARED_LOCAL_STORAGE?this._storageInterface.setSyncEnabled(!1):(this._config.SYNCING_ENABLED=!1,this.getLoadedCollections().forEach((function(e){return e._abortPushOrPull()})))}},{key:"getLibraryById",value:function(e){return this.getLoadedCollections().reduce((function(t,n){return t||n.getLibraryById(e)}),null)}},{key:"getLibraryFolderById",value:function(e){return this.getLoadedCollections().find((function(e){return e.isPrivate})).platformFolders.find((function(t){return t.id===e}))}},{key:"resolveElementReference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=e.match(S);if(t){var n=i(t,4),o=n[2],r=n[3];return this.getLoadedCollections().map((function(e){var t=e.getLibraryById(o);return t&&t.getElementById(r)})).find((function(e){return e}))}}},{key:"resolveElementReferenceToLibrary",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=e.match(S);if(t){var n=i(t,3),o=n[1],r=n[2];return this.getLoadedCollections().map((function(e){if(o===e._syncManager.getElementRefDomainPath())return e.getLibraryById(r)})).find((function(e){return e}))}}},{key:"getAccessToken",value:function(e,t,n,i,o){this._config.SHARED_LOCAL_STORAGE?0!==this._collectionManager.getLoadedCollections().length?this._storageInterface.getAccessToken(e,t,n,i,o):o(new f(f.LOGGED_OUT,"User must be logged in to request an access token")):o(new f(f.NOT_SUPPORTED,"getAccessToken() is only supported with shared local storage"))}},{key:"openInCCD",value:function(e,t){this._config.SHARED_LOCAL_STORAGE?this._storageInterface.openInCCD(e,t):t(new f(f.NOT_SUPPORTED,"launchCCD() is only supported with shared local storage"))}},{key:"utils",get:function(){return this._externalUtils}},{key:"analyticsUtils",get:function(){return this._externalAnalyticsUtils}}])&&s(t.prototype,n),o&&s(t,o),e}();e.exports=b},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var r=n(11),a=n(61),s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._config=t,this._fileUtils=new a(this,t),this.uuid=n(21),("undefined"==typeof window?{}:window).nodeRequire&&(this.fs=("undefined"==typeof window?{}:window).nodeRequire("fs"),this.path=("undefined"==typeof window?{}:window).nodeRequire("path")),this._initDCX()}var t,s;return t=e,(s=[{key:"_initDCX",value:function(){var e=this;this.dcx=new r(this.fs,{preserveFileExtensions:!0,logCallback:function(t){return e._log&&e._log("DCX: "+t)}})}},{key:"log",value:function(e){this._log&&this._log("CC Libraries: "+e)}},{key:"hasFileSystem",value:function(){return void 0!==this.fs}},{key:"setFileSystem",value:function(e){this.fs=e,this._initDCX()}},{key:"hasRenditionGenerator",value:function(){return void 0!==this.renditionGenerator}},{key:"setRenditionGenerator",value:function(e){this.renditionGenerator=e}},{key:"getVulcanInterface",value:function(){if("undefined"!==("undefined"==typeof VulcanInterface?"undefined":i(VulcanInterface)))return VulcanInterface}},{key:"getVulcanMessage",value:function(){if("undefined"!==("undefined"==typeof VulcanMessage?"undefined":i(VulcanMessage)))return VulcanMessage}},{key:"hasCEPVulcan",value:function(){return void 0!==this.getVulcanInterface()&&void 0!==this.getVulcanMessage()}},{key:"getNodeTunnelOptions",value:function(e){return this._getNodeTunnelOptions?this._getNodeTunnelOptions(e):{}}},{key:"getPathSeparator",value:function(){return"/"}},{key:"getFileNameFromPath",value:function(e){return!e.includes("/")&&e.includes("\\")&&(e=e.replace(/\\/g,"/")),e.split("/").pop()}},{key:"fileUtils",get:function(){return this._fileUtils}}])&&o(t.prototype,s),e}();e.exports=s},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var o=n(0),r=n(2);function a(e,t,n){e?this._setData(e):this._data={},this._readOnly=t,this._isRoot=n}a.ROOT_PATH="/",Object.defineProperties(a.prototype,{id:{get:function(){return this._data.id},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._owner)throw new o(o.READ_ONLY,"Cannot change the id of a node that is part of a branch or element.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.id=e,this._setDirty()}},name:{get:function(){return this._data.name},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.name=e,this._setDirty()}},type:{get:function(){return this._data.type},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.type=e,this._setDirty()}},relationship:{get:function(){return this._data.rel},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.rel=e,this._setDirty()}},path:{get:function(){return this._isRoot?"/":this._data.path},set:function(e){if(e!==this.path){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._isRoot)throw new o(o.READ_ONLY,"Cannot change the path of the root node.");if(e&&!r.isValidPath(e))throw new o(o.INVALID_PARAMS,"Expecting a valid path or undefined.");this._owner?this._owner._setPathOfNode(this,e||void 0):(this._data.path=e||void 0,this._parentPath=""),this._setDirty()}}},parentPath:{get:function(){return this._parentPath},set:function(){throw new o(o.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get:function(){var e=this.path;return this._isRoot?e:e&&this._owner?r.appendPathElements(this._parentPath,e):void 0},set:function(){throw new o(o.READ_ONLY,"absolutePath is read-only.")}},isRoot:{get:function(){return this._isRoot},set:function(){throw new o(o.READ_ONLY,"isRoot is read-only.")}}}),a.prototype.getLink=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');return this._data._links?this._data._links[e]:void 0},a.prototype.setLink=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("object"!==i(e))throw new o(o.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var n=this._data._links;n||(n=this._data._links={}),n[t]=e,this._setDirty()},a.prototype.removeLink=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var t=this._data._links;t&&(delete t[e],Object.keys(t).length<1&&delete this._data._links,this._setDirty())};var s={components:!0,children:!0,"manifest-format-version":!0,id:!0,name:!0,type:!0,state:!0,local:!0},c={components:!0,children:!0,rel:!0,path:!0,id:!0,name:!0,type:!0};a.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),i=n.length;for(e=0;e<i;e++){var o=n[e];(this._isRoot?s[o]:c[o])||t.push(o)}return t},a.prototype.getValue=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");return this._data[e]},a.prototype.setValue=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");this._data[e]=t,this._setDirty()},a.prototype.removeValue=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");delete this._data[e],this._setDirty()},a.prototype.copy=function(){var e=null,t=this._data.children,n=this._data.components;try{t&&delete this._data.children,n&&delete this._data.components,e=new a(JSON.parse(JSON.stringify(this._data)))}finally{t&&(this._data.children=t),n&&(this._data.components=n)}return e},a.prototype.isEqualTo=function(e,t,n){return this._isEqual(this._data,e._data,r.merge({children:!0,components:!0},t),n)},a.prototype._isEqual=function(e,t,n,i){var o,a,s,c,l,u,h;if(!r.objectsEqual(e,t,n))return!1;if(a=e.components,s=t.components,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(o=0;o<c;o++){for(l=a[o],u=null,h=0;h<c;h++)if(l.id===s[h].id){u=s[h];break}if(!u)return!1;if(!r.objectsEqual(l,u,i))return!1}if(a=e.children,s=t.children,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(o=0;o<c;o++)if(!this._isEqual(a[o],s[o],n,i))return!1;return!0},a.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t},a.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Node is missing an id of type string"):null},a.prototype._setDirty=function(){this._owner&&this._owner._setDirty()},e.exports=a},function(e,t,n){(function(t){var n,i=void 0!==t&&(t.crypto||t.msCrypto);if(i&&i.getRandomValues){var o=new Uint8Array(16);n=function(){return i.getRandomValues(o),o}}if(!n){var r=new Array(16);n=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}e.exports=n}).call(this,n(47))},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"===(void 0===("undefined"==typeof window?{}:window)?"undefined":n("undefined"==typeof window?{}:window))&&(i="undefined"==typeof window?{}:window)}e.exports=i},function(e,t){for(var n=[],i=0;i<256;++i)n[i]=(i+256).toString(16).substr(1);e.exports=function(e,t){var i=t||0,o=n;return o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]}},function(e,t,n){var i=n(19),o=n(0),r=n(2);function a(e,t,n){this._owner=t,e?e=this._setData(e,n):(e={id:r.generateUuid()},this._core=new i(e,this,n),this._data=e)}Object.defineProperties(a.prototype,{rootNode:{get:function(){return this._core.rootNode},set:function(e){this._core.rootNode=e}},name:{get:function(){return this._core.rootNode.name},set:function(e){var t=this._core;if(t._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get:function(){return this._core.rootNode.type},set:function(e){var t=this._core;if(t._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get:function(){return this._owner.compositeHref},set:function(){throw new o(o.READ_ONLY,'Property "compositeHref" is read-only.')}},_localStorage:{get:function(){return this._core._localStorage},set:function(e){this._core._localStorage=e}},hasLocalStorage:{get:function(){return this._core.hasLocalStorage},set:function(e){this._core.hasLocalStorage=e}},_isDirty:{get:function(){return this._core._isDirty},set:function(e){this._core._isDirty=e}},isDirty:{get:function(){return this._isDirty},set:function(e){this._core.isDirty=e}},changeCount:{get:function(){return this._core.changeCount},set:function(e){this._core.changeCount=e}}}),a.prototype.getChildWithId=function(e){return this._core.getChildWithId(e)},a.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e)},a.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e)},a.prototype.addChild=function(e,t,n,i){return this._core.addChild(e,t,n,i)},a.prototype.removeChild=function(e){return this._core.removeChild(e)},a.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n)},a.prototype.copyChild=function(e,t,n,i,o,r){return this._core.copyChild(e,t,n,i,o,r)},a.prototype.allComponents=function(){return this._core.allComponents()},a.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e)},a.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e)},a.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e)},a.prototype.addComponent=function(e,t,n,i,o,r,a,s,c,l){return this._core.addComponent(e,t,n,i,o,r,a,s,c,l)},a.prototype.addComponentWithUploadResults=function(e,t,n,i,o){return this._core.addComponentWithUploadResults(e,t,n,i,o)},a.prototype.updateComponent=function(e,t,n,i){return this._core.updateComponent(e,t,n,i)},a.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t)},a.prototype.removeComponent=function(e){return this._core.removeComponent(e)},a.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t)},a.prototype.copyComponent=function(e,t,n,i,o){return this._core.copyComponent(e,t,n,i,o)},a.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},a.prototype.parse=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new o(o.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message)}return this._setData(t,this._core._readOnly)},a.prototype.copy=function(){return new a(JSON.parse(JSON.stringify(this._data)),this._owner)},a.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new o(o.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core)},a.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Element is missing an id of type string"):"string"!=typeof e.name?new o(o.INVALID_DATA,"Element is missing a name of type string"):"string"!=typeof e.type?new o(o.INVALID_DATA,"Element is missing a type of type string"):null},a.prototype._setData=function(e,t){var n=this._verify(e);if(null===n)return this._core=new i(e,this,t),this._data=e,this;throw n},a.prototype._local=function(){return this._core._local()},a.prototype._setDirty=function(e){this._core._setDirty(e)},a.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t)},a.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n)},e.exports=a},function(e,t,n){var i=n(0),o=n(2),r=n(5),a=n(51);function s(e,t){if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e,this._preserveFileExtensions=t,this._inMemoryBranchesAndElements=[],this._inflightComponents=[]}Object.defineProperties(s.prototype,{compositePath:{get:function(){return this._compositePath},set:function(e){if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e}}}),s.prototype.currentManifestPath=function(){return this._compositePath+"/manifest"},s.prototype.currentBaseManifestPath=function(){return this._compositePath+"/manifest.base"},s.prototype.pulledManifestPath=function(){return this._compositePath+"/pull.manifest"},s.prototype.pushedManifestPath=function(){return this._compositePath+"/push.manifest"},s.prototype.resolvePulledBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",(function(e){e?(e.code!==i.OUT_OF_SPACE&&(e=new i(i.INVALID_STATE,"Could not write current manifest.",e)),t(e)):r.move(n.pulledManifestPath(),n.currentBaseManifestPath(),!1,(function(e){e?t(new i(i.INVALID_STATE,"Could not move pull manifest.",e)):(n._pullJournal&&n._pullJournal.clear(),t())}))}))},s.prototype.acceptPushedBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",(function(e){e?(e.code!==i.OUT_OF_SPACE&&(e=new i(i.INVALID_STATE,"Could not write current manifest.",e)),t(new i(i.INVALID_STATE,"Could not write current manifest.",e))):r.move(n.pushedManifestPath(),n.currentBaseManifestPath(),!1,(function(e){e?t(new i(i.INVALID_STATE,"Could not move push manifest.",e)):n._deleteJournal(t)}))}))},s.prototype.discardPulledBranch=function(e){r.deleteFile(this.pulledManifestPath(),e)},s.prototype.discardPushedBranch=function(e){var t=this;r.deleteFile(this.pushedManifestPath(),(function(n){n?e(n):t._deleteJournal(e)}))},s.prototype.discardBaseBranch=function(e){r.deleteFile(this.currentBaseManifestPath(),e)},s.prototype.registerInMemoryBranchOrElement=function(e){if(this._inMemoryBranchesAndElements.indexOf(e)>=0)throw new i(i.INVALID_STATE,"Branch or element is already registered.");this._inMemoryBranchesAndElements.push(e)},s.prototype.unregisterInMemoryBranchOrElement=function(e){var t=this._inMemoryBranchesAndElements.indexOf(e);if(t<0)throw new i(i.INVALID_STATE,"Unknown branch or element.");this._inMemoryBranchesAndElements.splice(t,1)},s.prototype._deleteJournal=function(e){r.deleteFile(this.pushJournalPath(),e)};var c=/(\/)|(\.$)/;s.prototype.componentAssetName=function(e,t){var n=t["copyOnWrite#storageIds"],i=n?n[e.id]:null;return i&&c.test(i)&&(i=null),i},s.prototype.componentAssetPath=function(e,t){var n=this.componentAssetName(e,t);return n?this._componentPathFromName(n):null},s.prototype.ingestComponentAsset=function(e,t,n,o,a){var s=this,c=this._newFileNameForComponent(e),l=this._componentPathFromName(c);this._inflightComponents.push(c);var u=function(t){if(!t)try{s._setComponentName(e,o,c)}catch(e){t=e}var n=s._inflightComponents.indexOf(c);n<0&&!t&&(t=new i(i.INVALID_STATE,"Could not find inflight component.")),s._inflightComponents.splice(n,1),a(t)};n?r.copyFile(t,l,u):r.move(t,l,!0,u)},s.prototype.removeComponentAsset=function(e,t){var n=t["copyOnWrite#storageIds"];n&&delete n[e.id]},s.prototype.componentIds=function(e){var t=e["copyOnWrite#storageIds"];return t?Object.keys(t):[]},s.prototype.copyLocalStorageData=function(e,t,n,i){var o,r=n.allComponents(),a=r.length,s=t["copyOnWrite#storageIds"];if(s){var c=i["copyOnWrite#storageIds"];for(c||(c=i["copyOnWrite#storageIds"]={}),o=0;o<a;o++){var l=r[o],u=l.id,h=e.getComponentWithId(u);if(h&&h.etag===l.etag){var p=s[u];p&&(c[u]=p)}}}},s.prototype.removeUnusedLocalFiles=function(e,t){var n,o,a,s,c,l=this,u=function(e){l._deleteComponentAsset(e,(function(e){e&&!n&&(n=e),0==--c&&t(n)}))},h=function(){try{var e,n=s.length,i=[];for(e=0;e<n;e++){var r=s[e].name,h=s[e].info;!o[r]&&h.mtime.getTime()<a&&l._inflightComponents.indexOf(r)<0&&i.push(r)}if((c=n=i.length)>0)for(e=0;e<n;e++)u(i[e])}catch(e){return void t(e)}0===c&&t()};this._gatherComponentAssetNames([this.currentManifestPath(),this.currentBaseManifestPath(),this.pulledManifestPath(),this.pushedManifestPath()],e,(function(e,r,c,l){if(n)t(n);else{if(!e)try{if(r<1||!l)throw new i(i.INVALID_STATE,r<1?"No manifest found.":"Invalid time stamp");o=c,a=l}catch(t){e=t}e&&(n=e),s&&(n?t(n):h())}})),r.directoryListing(this._compositePath+"/components",(function(e,i){if(n)t(n);else{if(!e)try{s=i}catch(t){e=t}e&&(n=e),o&&(n?t(n):h())}}))},s.prototype.tempPathForComponent=function(){return this._compositePath+"/tmp/"+o.generateUuid()},s.prototype.deleteTempFiles=function(e){r.deleteDirectory(this._compositePath+"/tmp",e)},s.prototype.clientDataPath=function(){return this._compositePath+"/clientdata"},s.prototype.pushJournalPath=function(){return this._compositePath+"/push.journal"},s.prototype.pullJournalPath=function(){return this._compositePath+"/pull.journal"},s.prototype.loadPullJournal=function(){return this._pullJournal?Promise.resolve(this._pullJournal):(this._pullJournal=new a(this.pullJournalPath()),this._pullJournal.load())},s.prototype._copyComponentMapping=function(e,t,n,i){var o=t["copyOnWrite#storageIds"];if(o){var r=i["copyOnWrite#storageIds"];r||(r=i["copyOnWrite#storageIds"]={});var a=o[e];return a&&(r[n]=a),a}},s.prototype._componentPathFromName=function(e){return this._compositePath+"/components/"+e},s.prototype._newFileNameForComponent=function(e){var t=o.generateUuid();if(this._preserveFileExtensions){var n=e.path?o.filePathComponents(e.path).extension:null;n&&(t=t+"."+n)}return t},s.prototype._setComponentName=function(e,t,n){var i=t["copyOnWrite#storageIds"];i||(i=t["copyOnWrite#storageIds"]={}),i[e.id]=n},s.prototype._gatherComponentAssetNames=function(e,t,n){try{var i,a,s={},c=t||o.timeStamp(!0),l=e.length,u=l,h=0,p=function(e){if(e){e=e["copyOnWrite#storageIds"];var t,n=Object.keys(e);for(t=0;t<n.length;t++){var i=e[n[t]];s[i]=!0}}},d=function(e){r.exists(e,(function(t){t?(h++,r.info(e,(function(t,i){if(!t)try{var o=i.mtime.getTime();o<c&&(c=o),r.readFile(e,"utf8",(function(e,t){if(u--,!e)try{t=JSON.parse(t),p(t.local)}catch(t){e=t}e&&!a&&(a=e),0===u&&n(a,h,s,c)}))}catch(e){t=e}t&&(u--,a||(a=t),0===u&&n(a))}))):0==--u&&n(a,h,s,c)}))};for(i=0;i<l;i++)d(e[i]);for(l=this._inMemoryBranchesAndElements.length,i=0;i<l;i++)p(this._inMemoryBranchesAndElements[i]._local())}catch(e){n(e)}},s.prototype._deleteComponentAsset=function(e,t){r.deleteFile(this._componentPathFromName(e),t)},e.exports=s},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(5),r=n(2),a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._filePath=t,this._data={version:1,downloadedComponents:{}}}var t,n;return t=e,(n=[{key:"saveComponentPath",value:function(e){var t=e._owner;return this._data.downloadedComponents=this._data.downloadedComponents||[],this._data.downloadedComponents[e.id]={version:e.version,path:t._localStorage.componentAssetName(e,t._local())},this.save()}},{key:"restoreComponentPath",value:function(e){var t=e._owner,n=this._data.downloadedComponents[e.id];return!(!n||n.version!==e.version||(t._localStorage._setComponentName(e,t._local(),n.path),0))}},{key:"clear",value:function(){return this._data.downloadedComponents=[],this.save()}},{key:"load",value:function(){var e=this;return new Promise((function(t){o.readFile(e._filePath,"utf8",(function(n,i){var o;try{o=JSON.parse(i)}catch(n){}o&&1===o.version&&o.downloadComponents&&(e._data=o),t(e)}))}))}},{key:"_doSave",value:function(){var e=this;return new Promise((function(t){var n=function(e){e&&r.log("Error writing pull journal: ".concat(e)),t()};0===e._data.downloadedComponents.length?o.deleteFile(e._filePath,n):o.writeFileAtomically(e._filePath,JSON.stringify(e._data),"utf8",n)}))}},{key:"save",value:function(){var e=this;return this._savingPromise?this._pendingSave=!0:this._savingPromise=this._doSave().then((function(){if(delete e._savingPromise,e._pendingSave)return delete e._pendingSave,e.save()})),this._savingPromise}}])&&i(t.prototype,n),e}();e.exports=a},function(e,n,i){var o,r=i(2),a=i(0),s=i(5),c=i(14),l=i(23),u=i(53).TextEncoder;o=("undefined"==typeof window?{}:window).XMLHttpRequest;var h=r.merge;function p(e){this._requestQueue=[],this._requestsOutstanding=[],this._rejectedAuths=[],this._authCallback=e,this._isActive=!0,this._waitingForAuthentication=!!e,this._currentAuthId=r.generateUuid(),this._https=void 0,this._XMLHttpRequest=o,this._handlesRedirects=void 0!==o,this._maxOutstanding=5}Object.defineProperties(p.prototype,{isActive:{get:function(){return this._isActive},set:function(e){this._isActive!==e&&(this._isActive=e,e||(this._authValue=void 0,this._checkQueue()))}},crossOriginCredentials:{get:function(){return this._withCredentials},set:function(e){this._withCredentials=e}},maxOutstanding:{get:function(){return this._maxOutstanding},set:function(e){this._maxOutstanding=e,this._checkQueue()}},handlesRedirects:{get:function(){return this._handlesRedirects}}}),p.prototype._forceXhr=function(e,t){this._https=void 0,this._XMLHttpRequest=e||o,this._handlesRedirects=!t},p.prototype.setAdditionalHeaders=function(e){this._additionalHeaders=e||{}},p.prototype.setAdditionalNodeOptions=function(e){this._additionalNodeOptions=e},p.prototype.setApiKey=function(e){this._apiKey=e},p.prototype.setTimeout=function(e){this._timeout=e},p.prototype.setAuthToken=function(e){e?(this._authValue="Bearer "+e,this.resume()):(this._authValue=void 0,this._currentAuthId=r.generateUuid())},p.prototype.resume=function(){this._currentAuthId=r.generateUuid(),this._waitingForAuthentication=!1,this._checkQueue()},p.prototype.setRequestHooks=function(e,t){this._beforeHook=e,this._afterHook=t},p.prototype.invoke=function(e,n,i,o,l,u){if(void 0===n)return u(new a(a.INVALID_PARAMS,"No href provided"));var p=(l=l||{}).responseType;if(p instanceof c){if(!s.canUseFileSystem)throw new a(a.INVALID_PARAMS,"No filesystem access")}else if("buffer"===p){if("function"!=typeof t)throw new a(a.INVALID_PARAMS,"No Buffer class")}else if("blob"===p){if("function"!=typeof Blob)throw new a(a.INVALID_PARAMS,"No Blob class")}else if(p&&"text"!==p&&"json"!==p&&"arraybuffer"!==p)throw new a(a.INVALID_PARAMS,"Unsupported response type");i=h({},i,this._additionalHeaders),this._apiKey&&(i["x-api-key"]=this._apiKey);var d={method:e,href:n,headers:i,callback:u,body:o,options:l},_=l.reuseRequestDesc;if(_){if(this._requestQueue.indexOf(_)>=0||this._requestsOutstanding.indexOf(_)>=0)throw new a(a.INVALID_PARAMS,"Request descriptor still in use.");d=r.merge(_,d)}return this._doRequest(d),d},p.prototype._getSize=function(e){return new Promise((function(t){e instanceof c?s.info(e.filename,(function(e,n){return t(n&&n.size)})):"string"==typeof e?t((new u).encode(e).length):t()}))},p.prototype._doRequest=function(e){var n,i,o,u=this,p=this,d=0,_=[],f=e.body,m=e.options.responseType;function v(t,n){if(t)r.log("["+e.id+"] error: "+t);else{var o=(new Date).valueOf()-e.startTime;n.complete?r.log("["+e.id+"] success ("+o+"ms)"):r.log("["+e.id+"] success ("+o+"ms) but response is incomplete")}var s=p._requestsOutstanding.indexOf(e);s>=0&&p._requestsOutstanding.splice(s,1);var c=e.callback;c&&(e.callback=void 0,t&&(t.clientRequest=e.clientRequest,t.xhr=e.xhr),t&&t.code!==a.SERVICE_IS_INACTIVE&&!p._isActive?t=new a(a.SERVICE_IS_INACTIVE,"Service is now inactive",t):e.timedOut&&(t=new a(a.TIMED_OUT,"timed out request",t)),c(t,n)),i&&i.end(),p._isActive&&p._checkQueue()}if(!this._isActive)return v(new a(a.SERVICE_IS_INACTIVE,"Network request in inactive state"));function y(n){var o=!1,l=!1,u=!1;function h(){if(!l)return l=!0,i=void 0,v(void 0,n)}var d=p._requestsOutstanding.indexOf(e);if(d<0)p._checkQueue();else{e.response=n;var f=(new Date).valueOf()-e.startTime;if(r.log("["+e.id+"] "+n.statusCode+" ("+f+"ms)"),401===n.statusCode&&p._authCallback)p._requestsOutstanding.splice(d,1),p._requestQueue.unshift(e),p._authFail(e),r.consumeStream(n);else{var y=e.progress;200===n.statusCode||201===n.statusCode||202===n.statusCode?(n.on("data",(function(e){e.length&&y&&y(e.length),!i&&e&&_.push(e)})),p._https&&m instanceof c&&(i=s.createWriteStream(m.filename),n.pipe(i),o=!0)):r.consumeStream(n),n.once("end",(function(){u=!0;var i=p._requestsOutstanding.indexOf(e);if(!(i<0||(p._requestsOutstanding.splice(i,1),p._checkQueue(),o||l)))return l=!0,n.response=t.concat(_),"arraybuffer"===m?n.response=new ArrayBuffer(n.response):"text"===m&&(n.response=n.response.toString()),v(void 0,n)}));var g=function(){if(!u&&!l)return l=!0,v(new a(a.NETWORK_ERROR,"incomplete response"))};n.once("close",g),n.once("aborted",(function(){n.complete||g()})),o&&(i.once("finish",h),i.once("close",h))}}}function g(t){t.pipe(o),t.on("error",(function(t){v(new a(a.TERMINATED_INPUTSTREAM,"Input stream terminated abnormally",t)),p.abort(e)}))}if(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||e.options.noSoonerThen)this._requestQueue.push(e),this._waitingForAuthentication||this._checkQueue();else{var E=e.headers;if(0!==e.href.indexOf("https:"))return v(new a(a.INVALID_PARAMS,"http not supported - network requests must use https"));if(null===E.Authorization?delete E.Authorization:this._authValue&&(E.Authorization=this._authValue),this._currentAuthId&&(e.authId=this._currentAuthId),this._beforeHook&&this._beforeHook(e),e.id=r.generateUuid(),e.startTime=(new Date).valueOf(),null!==E["X-Request-Id"]?E["X-Request-Id"]=e.id:delete E["X-Request-Id"],this._https){this._requestsOutstanding.push(e);var O=(void 0).parse(e.href),A=h({},this._additionalNodeOptions,O);A.method=e.method||"GET",A.headers=E,r.log("["+e.id+"] "+A.method+" "+e.href),this._getSize(f).then((function(n){n&&(null===A.headers["Content-Length"]?delete A.headers["Content-Length"]:void 0===A.headers["Content-Length"]&&(A.headers["Content-Length"]=n)),o=u._https.request(A,y),e.clientRequest=o,o.once("error",v),o.once("abort",(function(){return v(new a(a.NETWORK_ERROR,"Request aborted"))})),p._timeout&&o.setTimeout(p._timeout,(function(){e.timedOut=!0,o.abort()})),e.bytesSent=0,e.bytesReported=0,o.once("end",(function(){if(e.progress){var t=e.bytesSent-e.bytesReported;t>0&&(e.progress(t),e.bytesReported+=t)}}));var i=o.write;if(o.write=function(t){var n=t&&t.length;return n&&(e.bytesSent+=n),i.call(o,t,(function(){e.progress&&t&&(e.progress(n),e.bytesReported+=n)}))},f instanceof c)g(s.createReadStream(f.filename,f.range));else if(f instanceof l)f.getStream?g(f.getStream()):f.getStreamAsync&&f.getStreamAsync((function(t,n){if(t)return v(new a(a.TERMINATED_INPUTSTREAM,"Error creating input stream",t)),void p.abort(e);g(n)}));else if(f instanceof t)o.write(f),o.end();else if(f instanceof ArrayBuffer)o.write(t.from(new Int8Array(f))),o.end();else if("string"==typeof f)o.write(t.from(f,"utf8")),o.end();else{if(f)return v(new a(a.INVALID_PARAMS,"Invalid data type"));o.end()}u._afterHook&&u._afterHook(e,o)})).catch(v)}else{if(f instanceof c)return s.canUseFileSystem?void s.readFile(f.filename,{},(function(t,n){if(t)return v(t);e.body=n,p._doRequest(e)})):v(new a(a.INVALID_PARAMS,"Can't use FileContent without filesystem support"));var S;for(S in"function"==typeof t&&f instanceof t&&(e.body=f=new Int8Array(f)),this._requestsOutstanding.push(e),r.log("["+e.id+"] "+e.method+" "+e.href),(n=new this._XMLHttpRequest).open(e.method,e.href,!0),this._withCredentials&&(n.withCredentials=!0),m&&(n.responseType=m instanceof c?"buffer":m),n.onreadystatechange=function(){var t=e.progress;if(t&&n.response){var i=n.response.length;t(i-d),d=i}if(4===n.readyState){if(0===n.status)return v(new a(a.UNEXPECTED,"XHR failure"));var o=p._requestsOutstanding.indexOf(e);if(o<0)p._checkQueue();else{var l=(new Date).valueOf()-e.startTime;if(r.log("["+e.id+"] "+n.status+" ("+l+"ms)"),p._requestsOutstanding.splice(o,1),401!==n.status||!p._authCallback){if(e.xhr=n,e.response=n,n.statusCode=n.status,n.headers=r.parseHeaders(n.getAllResponseHeaders()),m instanceof c){var u=n.response.response;return void s.writeFileAtomically(m.filename,u,void 0,(function(e){return e?v(new a(a.UNEXPECTED,"Can't create file",e,n)):v(void 0,n)}))}return t&&f&&t(f.length||f.size),v(void 0,n)}p._requestQueue.unshift(e),p._authFail(e),p._checkQueue()}}},E)E.hasOwnProperty(S)&&n.setRequestHeader(S,E[S]);e.xhr=n,p._timeout&&(n.timeout=p._timeout,n.ontimeout=function(){e.timedOut=!0,n.abort()}),f?n.send(f):n.send(),this._afterHook&&this._afterHook(e,n)}}},p.prototype._authFail=function(e){if(this._authCallback){var t=e.authId;if(-1!==this._rejectedAuths.indexOf(t))return;this._authValue=null,this._waitingForAuthentication=!0,this._rejectedAuths.unshift(t)>this._maxOutstanding&&(this._rejectedAuths.length=this._maxOutstanding),this._authCallback(this)}},p.prototype._checkQueue=function(){if(!this._isActive){var e=this._requestsOutstanding;this._requestsOutstanding=[],e.forEach((function(e){e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort();var t=e.callback;t&&(e.callback=void 0,t(new a(a.SERVICE_IS_INACTIVE,"Network request in inactive state")))}));var t=this._requestQueue;return this._requestQueue=[],t.forEach((function(e){var t=new a(a.SERVICE_IS_INACTIVE,"Network request in inactive state"),n=e.callback;n&&(e.callback=void 0,n(t))})),void(this._checkQueueTimerId&&(clearTimeout(this._checkQueueTimerId),this._checkQueueTimerId=void 0,this._checkQueueTimerWhen=void 0))}for(var n,i=Date.now(),o=i+3e5,r=0;!(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||r>=this._requestQueue.length);){var s=this._requestQueue[r];(n=s.options.noSoonerThen||i)&&n>o&&(n=s.options.noSoonerThen=o),n<=i?(this._requestQueue.splice(r,1),s.options.noSoonerThen=void 0,this._doRequest(s)):r++}if(!this._waitingForAuthentication&&this._requestsOutstanding.length<this._maxOutstanding&&this._requestQueue.length>0){var c,l,u=this._requestQueue.length;for(l=0;l<u;l++)(n=this._requestQueue[l].options.noSoonerThen)&&n>o&&(n=this._requestQueue[l].options.noSoonerThen=o),n&&(c=c&&c<n?c:n);if(c&&(!this._checkQueueTimerWhen||this._checkQueueTimerWhen>c)){this._checkQueueTimerId&&clearTimeout(this._checkQueueTimerId),this._checkQueueTimerWhen=c;var h=this;this._checkQueueTimerId=setTimeout((function(){h._checkQueueTimerWhen=void 0,h._checkQueueTimerId=void 0,h._checkQueue()}),c-i)}}},p.prototype.abort=function(e){var t=this._requestQueue.indexOf(e);t>=0?this._requestQueue.splice(t,1):(t=this._requestsOutstanding.indexOf(e))>=0&&(this._requestsOutstanding.splice(t,1),e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort(),this._checkQueue())};var d=function(e){var t=e&&e.callback;t&&(e.callback=void 0,t(new a(a.NETWORK_ERROR,"Request aborted")))};p.prototype.abortAllWithToken=function(e){if(e){for(var t=0;t<this._requestQueue.length;++t){var n=this._requestQueue[t];n.token===e&&(d(n),this._requestQueue.splice(t,1),--t)}for(var i=0;i<this._requestsOutstanding.length;++i)if(this._requestsOutstanding[i].token===e){var o=this._requestsOutstanding[i];this._requestsOutstanding.splice(i,1),--i,o.xhr&&o.xhr.abort(),o.clientRequest&&o.clientRequest.abort()}this._checkQueue()}},p.prototype.abortAll=function(){this._requestQueue.slice().forEach(d),this._requestQueue=[],this._requestsOutstanding.slice().forEach((function(e){e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort()})),this._requestsOutstanding=[],this._checkQueue()},e.exports=p},function(e,t,n){(function(e){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var o=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},i=0;i<t.length;i++)n[t[i]]=Object.getOwnPropertyDescriptor(e,t[i]);return n},r=/%[sdj%]/g;t.format=function(e){if(!y(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(c(arguments[n]));return t.join(" ")}n=1;for(var i=arguments,o=i.length,a=String(e).replace(r,(function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++])}catch(e){return"[Circular]"}default:return e}})),s=i[n];n<o;s=i[++n])m(s)||!O(s)?a+=" "+s:a+=" "+c(s);return a},t.deprecate=function(n,i){if(void 0!==e&&!0===e.noDeprecation)return n;if(void 0===e)return function(){return t.deprecate(n,i).apply(this,arguments)};var o=!1;return function(){if(!o){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),o=!0}return n.apply(this,arguments)}};var a,s={};function c(e,n){var i={seen:[],stylize:u};return arguments.length>=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),f(n)?i.showHidden=n:n&&t._extend(i,n),g(i.showHidden)&&(i.showHidden=!1),g(i.depth)&&(i.depth=2),g(i.colors)&&(i.colors=!1),g(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=l),h(i,e,i.depth)}function l(e,t){var n=c.styles[t];return n?"["+c.colors[n][0]+"m"+e+"["+c.colors[n][1]+"m":e}function u(e,t){return e}function h(e,n,i){if(e.customInspect&&n&&b(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(i,e);return y(o)||(o=h(e,o,i)),o}var r=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return v(t)?e.stylize(""+t,"number"):f(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}(e,n);if(r)return r;var a=Object.keys(n),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(n)),S(n)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(n);if(0===a.length){if(b(n)){var c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","special")}if(E(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(A(n))return e.stylize(Date.prototype.toString.call(n),"date");if(S(n))return p(n)}var l,u="",O=!1,L=["{","}"];return _(n)&&(O=!0,L=["[","]"]),b(n)&&(u=" [Function"+(n.name?": "+n.name:"")+"]"),E(n)&&(u=" "+RegExp.prototype.toString.call(n)),A(n)&&(u=" "+Date.prototype.toUTCString.call(n)),S(n)&&(u=" "+p(n)),0!==a.length||O&&0!=n.length?i<0?E(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),l=O?function(e,t,n,i,o){for(var r=[],a=0,s=t.length;a<s;++a)R(t,String(a))?r.push(d(e,t,n,i,String(a),!0)):r.push("");return o.forEach((function(o){o.match(/^\d+$/)||r.push(d(e,t,n,i,o,!0))})),r}(e,n,i,s,a):a.map((function(t){return d(e,n,i,s,t,O)})),e.seen.pop(),function(e,t,n){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n  ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(l,u,L)):L[0]+u+L[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,i,o,r){var a,s,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),R(i,o)||(a="["+o+"]"),s||(e.seen.indexOf(c.value)<0?(s=m(n)?h(e,c.value,null):h(e,c.value,n-1)).indexOf("\n")>-1&&(s=r?s.split("\n").map((function(e){return"  "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return"   "+e})).join("\n")):s=e.stylize("[Circular]","special")),g(a)){if(r&&o.match(/^\d+$/))return s;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function _(e){return Array.isArray(e)}function f(e){return"boolean"==typeof e}function m(e){return null===e}function v(e){return"number"==typeof e}function y(e){return"string"==typeof e}function g(e){return void 0===e}function E(e){return O(e)&&"[object RegExp]"===L(e)}function O(e){return"object"===i(e)&&null!==e}function A(e){return O(e)&&"[object Date]"===L(e)}function S(e){return O(e)&&("[object Error]"===L(e)||e instanceof Error)}function b(e){return"function"==typeof e}function L(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(n){if(g(a)&&(a=e.env.NODE_DEBUG||""),n=n.toUpperCase(),!s[n])if(new RegExp("\\b"+n+"\\b","i").test(a)){var i=e.pid;s[n]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",n,i,e)}}else s[n]=function(){};return s[n]},t.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=_,t.isBoolean=f,t.isNull=m,t.isNullOrUndefined=function(e){return null==e},t.isNumber=v,t.isString=y,t.isSymbol=function(e){return"symbol"===i(e)},t.isUndefined=g,t.isRegExp=E,t.isObject=O,t.isDate=A,t.isError=S,t.isFunction=b,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===i(e)||void 0===e},t.isBuffer=n(55);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function C(){var e=new Date,t=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":");return[e.getDate(),I[e.getMonth()],t].join(" ")}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",C(),t.format.apply(t,arguments))},t.inherits=n(56),t._extend=function(e,t){if(!t||!O(t))return e;for(var n=Object.keys(t),i=n.length;i--;)e[n[i]]=t[n[i]];return e};var P="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function D(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(P&&e[P]){var t;if("function"!=typeof(t=e[P]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,P,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,i=new Promise((function(e,i){t=e,n=i})),o=[],r=0;r<arguments.length;r++)o.push(arguments[r]);o.push((function(e,i){e?n(e):t(i)}));try{e.apply(this,o)}catch(e){n(e)}return i}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),P&&Object.defineProperty(t,P,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,o(e))},t.promisify.custom=P,t.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function n(){for(var n=[],i=0;i<arguments.length;i++)n.push(arguments[i]);var o=n.pop();if("function"!=typeof o)throw new TypeError("The last argument must be of type Function");var r=this,a=function(){return o.apply(r,arguments)};t.apply(this,n).then((function(t){e.nextTick(a,null,t)}),(function(t){e.nextTick(D,t,a)}))}return Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.defineProperties(n,o(t)),n}}).call(this,n(54))},function(e,t){var n,i,o=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===r||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:r}catch(e){n=r}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var c,l=[],u=!1,h=-1;function p(){u&&c&&(u=!1,c.length?l=c.concat(l):h=-1,l.length&&d())}function d(){if(!u){var e=s(p);u=!0;for(var t=l.length;t;){for(c=l,l=[];++h<t;)c&&c[h].run();h=-1,t=l.length}c=null,u=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function _(e,t){this.fun=e,this.array=t}function f(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new _(e,t)),1!==l.length||u||s(d)},_.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=f,o.addListener=f,o.once=f,o.off=f,o.removeListener=f,o.removeAllListeners=f,o.emit=f,o.prependListener=f,o.prependOnceListener=f,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}e.exports=function(e){return e&&"object"===n(e)&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(24),u=n(0),h=n(8),p=n(26),d=u.networkError,_=u.unexpectedResponse,f=n(2),m=f.appendPathElements,v=/^https:\/\/platform-cs(?:-stage)?(?:-[a-zA-Z0-9]+)?\.adobe\.io/,y=function(e){function t(e,n,i,o){var a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(a=r(this,s(t).call(this,e,n,i)))._platformEndpoint=o,a}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"getCollection",value:function(e,t,n){if(!(e=this._resolveUrl(e)))return n(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+e));var i;e+="?order=asc&orderby=name";var o={};t&&(o["If-None-Match"]=t);var r=this;return this._service.invoke("GET",e,o,void 0,{responseType:"text"},(function t(a,s){if(a)return n(d("Error retrieving a collection",a,s));if(200===s.statusCode){var c,l=s.responseText||s.response;try{c=JSON.parse(l)}catch(e){return(a=new u(u.INVALID_DATA,"Invalid JSON returned by server",e)).response=s,n(a)}i?i.children=i.children.concat(c.children):i=c;var h=s.headers["x-children-next-start"];if(h){var p=e+"&start="+h;r._service.invoke("GET",p,o,void 0,{responseType:"text"},t)}else n(void 0,i,s.headers.etag,s.headers)}else 304===s.statusCode?n(void 0,null,s.headers.etag,s.headers):n(_("Unexpected status code while getting a collection",void 0,s))}))}},{key:"pagedGetCollection",value:function(e,t,n,i,o,r,a,s){if(!(e=this._resolveUrl(e)))return s(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+e));e+=function(e,t,n,i){var o=[t&&"order=".concat(t),e&&"orderBy=".concat(e),n&&"start=".concat(n),i&&"limit=".concat(i)].filter((function(e){return e}));return 0===o.length?"":"?".concat(o.join("&"))}(n,i,o,r);var c={};return t&&(c["If-None-Match"]=t),this._service.invoke("GET",e,c,void 0,{responseType:"text"},(function(e,t){if(e)return s(d("Error retrieving a collection",e,t));if(200===t.statusCode){var n,i=t.responseText||t.response;try{n=JSON.parse(i)}catch(n){return(e=new u(u.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,s(e)}a?a.children=a.children.concat(n.children):a=n,s(void 0,a,t.headers.etag,t.headers)}else 304===t.statusCode?s(void 0,null,t.headers.etag,t.headers):s(_("Unexpected status code while getting a collection",void 0,t))}))}},{key:"getComponent",value:function(e,t,n){var i=this.getComponentHref(e,e.version);return this.getAsset(i,void 0,t,n)}},{key:"getRenditionOfComponent",value:function(e,t,n,i,o){var r=this.getComponentRenditionHref(e,e.version,n);return this.getAsset(r,{accept:t},i,o)}},{key:"getSyncGroups",value:function(e,t){var n=m(this._server,"assets");return this.getCollection(n,e,t)}},{key:"getSyncGroup",value:function(e,t,n){var i=m(this._server,"assets",e);return this.getCollection(i,t,n)}},{key:"getCompositeManifest",value:function(e,t,n){var i=e.href;return i&&(i=this._resolveUrl(i)),i?(i=m(i,"manifest"),this.getAssetAsType(i,"text",t,n)):n(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+i))}},{key:"createCompositeDirectory",value:function(e,t,n){var i=this,o=this._resolveUrl(e.href);if(!o)return n(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+o));function r(e,t,n){var r={"Content-Type":e.type,"X-Update":"content"};t&&(r["If-Match"]="*"),i._service.invoke("PUT",o,r,void 0,void 0,(function(t,i){if(t)return n(d("Error Creating composite directory",t,i));if(409===i.statusCode)return(t=new u(u.ALREADY_EXISTS,t)).response=i,n(t);try{var o=JSON.parse(i.response);o&&o.urn&&(e.assetId=o.urn)}catch(t){f.log("Could not get assetId from create response: ".concat(e.name))}n(void 0,i)}))}r(e,t,(function(a,s){if(a)return n(a);var c=s.statusCode;if(200===c||201===c)n(void 0,s);else if(404===c){var l=f.parentDirectory(o);i._service.invoke("PUT",l,{},void 0,void 0,(function(i,o){if(i)return n(d("Error creating composite directory",i,o));var a=o.statusCode;200===a||201===a||409===a?r(e,t,(function(e,t){if(e)return n(e);var i=t.statusCode;200===i||201===i?n(void 0,t):n(d("Error creating composite directory",e,t))})):n(_("Unexpected response creating composite directory",i,o))}))}else n(_("Unexpected response creating composite directory",a,s))}))}},{key:"deleteCompositeDirectory",value:function(e,t){var n=this,i=this._resolveUrl(e.href);if(!i)return t(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+i));i+="?recursive=true&invocation_mode=sync,async";var o=this._service.invoke("DELETE",i,{"If-Match":"*"},void 0,void 0,(function(e,i){if(e)return t(d("Error deleting composite directory",e,i));var r=i.statusCode;return 200===r||204===r||404===r?t(void 0,i):202===r?n._handle202Response(i,o,n.SYNC_ASYNC_DEFAULT_DELAY,void 0,t):void t(_("Unexpected response deleting composite directory",e,i))}))}},{key:"discardComposite",value:function(e,t){t(new u(u.INVALID_STATE,"Composites can only be discarded on platform."))}},{key:"uploadComponent",value:function(e,t,n,i,o,r){if(!e._owner||!e._owner.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");return this.uploadAssetForComponentId(e.id,e.type,e._owner.compositeHref,t,n,i,o,r)}},{key:"uploadAssetForComponentId",value:function(e,t,n,i,o,r,a,s){var c=this._constructComponentHref(n,e);return o&&(c+="?intermediates=false"),this.uploadAssetAtComponentHref(c,t,n,i,o,r,a,s)}},{key:"copyAssetToComponentId",value:function(e,t,n,i,o,r,a,s){var c=this._makeRelativeUrl(a);if(!c)return s(new u(u.WRONG_ENDPOINT,"Cannot copy asset: "+a));var l=this,h=this._constructComponentHref(n,e);h+="?invocation_mode=sync,async",o&&(h+="&intermediates=false");var p={};function f(e,t,n){e?delete p["If-Match"]:p["If-Match"]="*";var i=l._service.invoke("PUT",h,p,void 0,{responseType:"text"},(function(e,o){if(e)return n(d("Error uploading component",e,o));var r=o.statusCode;200===r||201===r||204===r?n(void 0,o,t):202===r?l._handle202Response(o,i,l.SYNC_ASYNC_DEFAULT_DELAY,void 0,(function(e,i){n(e,i,t)})):n(_("Unexpected response copying a component asset",e,o),o,t)}));return i.token=r,i}return t&&(p["Content-Type"]=t),p.Link="<"+c+">;rel=source",f(i,!0,(function e(t,n,o){var r;if(t){if(!(n=t.response))return s(t);var a=n.statusCode;o||404!==a&&409!==a&&412!==a?507===a?((t=new u(u.EXCEEDS_QUOTA,"Exceeds quota",t)).response=n,s(t)):s(t):f(!i,!0,e)}else{try{r=JSON.parse(n.responseText||n.response)}catch(e){return(t=new u(u.INVALID_DATA,"Invalid JSON returned by server",e)).response=n,s(t)}s(void 0,n,r)}}))}},{key:"updateManifest",value:function(e,t,n,i){var o=this.getBranchManifestHref(e);this.updateManifestAtHref(o,t,e.manifestEtag,n,i)}},{key:"getHrefForComposite",value:function(e,t){if(!e.type)throw new u(u.INVALID_STATE,"Composite needs a type");if(!e.id)throw new u(u.INVALID_STATE,"Composite needs an id");return e.href?e.href:this._resolveUrl(m("assets",t,e.id))}},{key:"getHrefForCompositeWithId",value:function(e,t){return this._resolveUrl(m("assets",t,e))}},{key:"getCompositeManifestHref",value:function(e){var t=this._resolveUrl(e.href);if(!t)throw new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+t);return m(t,"manifest")}},{key:"getBranchManifestHref",value:function(e){var t=this._resolveUrl(e.compositeHref);if(!t)throw new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+t);return m(t,"manifest")}},{key:"getComponentHref",value:function(e,t){var n,i=e._owner;if(!i||!i.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");return i._core&&(n=i._core._getSourceHrefOfComponent(e)),n&&this._resolveUrl(n)||this._constructComponentHref(i.compositeHref,e.id,t)}},{key:"getComponentRenditionHref",value:function(e,t,n){var i=e._owner;if(!i||!i.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(i._core&&i._core._getSourceHrefOfComponent(e))throw new u(u.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(i.compositeHref,e,t,n)}},{key:"_constructComponentHref",value:function(e,t,n){var i=m(this._resolveUrl(e),t);return i&&void 0!==n&&(i+=";version="+n),i}},{key:"_invokeOperation",value:function(e,t,n,i,o){var r=this,a="".concat(this._resolveUrl("/ops"),"?invocation_mode=sync,async"),s={op:e,id:f.generateUuid(),target:n,source:t};i&&(s.value=i),f.log("[invoke operation]: ".concat(JSON.stringify(s,void 0,2)));var c=function(e,t){var n;if(e)return(t=e.response)?void(507===t.statusCode?((e=new u(u.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,o(e)):o(e)):o(e);try{n=JSON.parse(t.responseText||t.response)}catch(n){return(e=new u(u.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,o(e)}if(n.error)return(e=new u(u.UNEXPECTED_RESPONSE,"Error in operation result: "+JSON.stringify(n.error,void 0,2))).response=t,o(e);o(void 0,t,n)},l=this._service.invoke("POST",a,{"Content-Type":"application/vnd.adobe.asset-operation+json"},JSON.stringify(s),{responseType:"text"},(function(t,n){if(t)return c(d("Error invoking operation "+e,t,n));var i=n.statusCode;200===i||201===i||204===i?c(void 0,n):202===i?r._handle202Response(n,l,r.SYNC_ASYNC_DEFAULT_DELAY,void 0,(function(e,t){c(e,t)})):c(_("Unexpected response for operation "+e,t,n),n)}));return l}},{key:"_constructComponentRenditionHref",value:function(e,t,n,i){var o=m(this._constructComponentHref(e,t.id),":rendition");return o+=";size="+(i||"full"),void 0!==n&&(o+=";version="+n),o}},{key:"_getTransientPlatformSession",value:function(){var e=this;return this._transientPlatformSession?Promise.resolve(this._transientPlatformSession):new Promise((function(t,n){var i=new p(e._service,e._platformEndpoint,v);i.getRootDocument((function(o){if(o)return n(o);e._transientPlatformSession=i,t(e._transientPlatformSession)}))}))}},{key:"_getCopyDelegate",value:function(e,n,i){var o=this;a(s(t.prototype),"_getCopyDelegate",this).call(this,e,n,(function(t,r){return t?v.test(e)?void o._doHeadRequest(n).then((function(t){var r=(t&&t.headers||{})["x-resource-urn"];if(!r)return i(new u(u.INVALID_DATA,"Request for composite did not return a URN: ".concat(n)));o._getTransientPlatformSession().then((function(t){t.getLinksFromUrn(r,(function(t,n){if(t)return i(new u(u.INVALID_DATA,"Could not get links for URN: ".concat(r)));var a=f.getUrlFromLinks(n,h.PRIMARY);i(null,(function(t,n,i,r,s,c){return o._transientPlatformSession.copyAssetToComponentId(t,n,a,i,r,s,e,c)}))}))}),i)})):i(new u(u.INVALID_PARAMS,"Href is not for a platform component: ".concat(e))):i(null,r)}))}}])&&o(n.prototype,i),t}(l);e.exports=y},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._requests=[],this._bytesTransferred=0}var t,i;return t=e,(i=[{key:"_onProgress",value:function(e){this._bytesTransferred+=e,this._progress&&this._progress(e)}},{key:"push",value:function(e,t){this._requests.push(e),e.token=this._token,t&&(e.progress=this._onProgress.bind(this))}},{key:"token",set:function(e){this._token=e,this._requests.forEach((function(t){return t.token=e}))}},{key:"progress",set:function(e){this._progress=e}},{key:"bytesSent",get:function(){return this._bytesTransferred}}])&&n(t.prototype,i),e}();e.exports=i},function(e,n,i){"use strict";function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var r=/^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i,a=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,s=/\s|\uFEFF|\xA0/,c=/\r?\n[\x20\x09]+/g,l=/[;,"]/,u=/[;,"]|\s/;function h(e){return e.replace(a,"")}function p(e){return s.test(e)}function d(e,t){for(;p(e[t]);)t++;return t}function _(e){return u.test(e)}var f=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.refs=[],t&&this.parse(t)}var t,n;return t=e,(n=[{key:"rel",value:function(e){for(var t=[],n=0;n<this.refs.length;n++)this.refs[n].rel===e&&t.push(this.refs[n]);return t}},{key:"get",value:function(e,t){e=e.toLowerCase();for(var n=[],i=0;i<this.refs.length;i++)this.refs[i][e]===t&&n.push(this.refs[i]);return n}},{key:"set",value:function(e){return this.refs.push(e),this}},{key:"has",value:function(e,t){e=e.toLowerCase();for(var n=0;n<this.refs.length;n++)if(this.refs[n][e]===t)return!0;return!1}},{key:"parse",value:function(t,n){for(var i=1,o=(t=h(t=(n=n||0)?t.slice(n):t).replace(c,"")).length,r=(n=0,null);n<o;)if(1===i){if(p(t[n])){n++;continue}if("<"!==t[n])throw new Error('Unexpected character "'+t[n]+'" at offset '+n);if(-1===(u=t.indexOf(">",n)))throw new Error("Expected end of URI delimiter at offset "+n);r={uri:t.slice(n+1,u)},this.refs.push(r),n=u,i=2,n++}else if(2===i){if(p(t[n])){n++;continue}if(";"===t[n])i=4,n++;else{if(","!==t[n])throw new Error('Unexpected character "'+t[n]+'" at offset '+n);i=1,n++}}else{if(4!==i)throw new Error('Unknown parser state "'+i+'"');if(";"===t[n]||p(t[n])){n++;continue}if(-1===(u=t.indexOf("=",n)))throw new Error("Expected attribute delimiter at offset "+n);var a=h(t.slice(n,u)).toLowerCase(),s="";if('"'===t[n=d(t,n=u+1)])for(n++;n<o;){if('"'===t[n]){n++;break}"\\"===t[n]&&n++,s+=t[n],n++}else{for(var u=n+1;!l.test(t[u])&&u<o;)u++;s=t.slice(n,u),n=u}switch(r[a]&&e.isSingleOccurenceAttr(a)||("*"===a[a.length-1]?r[a]=e.parseExtendedValue(s):(s="rel"===a||"type"===a?s.toLowerCase():s,null!=r[a]?Array.isArray(r[a])?r[a].push(s):r[a]=[r[a],s]:r[a]=s)),t[n]){case",":i=1;break;case";":i=4}n++}return r=null,this}},{key:"toString",value:function(){for(var t=[],n="",i=null,o=0;o<this.refs.length;o++)i=this.refs[o],n=Object.keys(this.refs[o]).reduce((function(t,n){return"uri"===n?t:t+"; "+e.formatAttribute(n,i[n])}),"<"+i.uri+">"),t.push(n);return t.join(", ")}}])&&o(t.prototype,n),e}();f.isCompatibleEncoding=function(e){return r.test(e)},f.parse=function(e,t){return(new f).parse(e,t)},f.isSingleOccurenceAttr=function(e){return"rel"===e||"type"===e||"media"===e||"title"===e||"title*"===e},f.isTokenAttr=function(e){return"rel"===e||"type"===e||"anchor"===e},f.escapeQuotes=function(e){return e.replace(/"/g,'\\"')},f.parseExtendedValue=function(e){var t=/([^']+)?(?:'([^']+)')?(.+)/.exec(e);return{language:t[2].toLowerCase(),encoding:f.isCompatibleEncoding(t[1])?null:t[1].toLowerCase(),value:f.isCompatibleEncoding(t[1])?decodeURIComponent(t[3]):t[3]}},f.formatExtendedAttribute=function(e,n){var i=(n.encoding||"utf-8").toUpperCase();return e+"="+i+"'"+(n.language||"en")+"'"+(t.isBuffer(n.value)&&f.isCompatibleEncoding(i)?n.value.toString(i):t.isBuffer(n.value)?n.value.toString("hex").replace(/[0-9a-f]{2}/gi,"%$1"):encodeURIComponent(n.value))},f.formatAttribute=function(e,t){return Array.isArray(t)?t.map((function(t){return f.formatAttribute(e,t)})).join("; "):"*"===e[e.length-1]||"string"!=typeof t?f.formatExtendedAttribute(e,t):(f.isTokenAttr(e)?t=_(t)?'"'+f.escapeQuotes(t)+'"':f.escapeQuotes(t):_(t)&&(t='"'+(t=(t=encodeURIComponent(t)).replace(/%20/g," ").replace(/%2C/g,",").replace(/%3B/g,";"))+'"'),e+"="+t)},e.exports=f},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(25),u=n(0),h=n(2),p=/^\/?content\/2\/[^/]+\/[^/]+/,d=/^\/?api\/v2\/[^/]+\/assets\/[^/]+/,_={"image/jpeg":"jpg","image/png":"png"},f=h.appendPathElements,m=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments))}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"getCompositeManifestHref",value:function(e){var t=this._resolveUrl(e.href);if(!t)throw new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+t);return f(t,"manifest")}},{key:"getComponent",value:function(e,t,n){var i=this.getComponentHref(e,e.version);return this.getAsset(i,void 0,t,n)}},{key:"getRenditionOfComponent",value:function(e,t,n,i,o,r){var a=this.getComponentRenditionHref(e,e.version,t,n,i);return this.getAsset(a,{accept:t},o,r)}},{key:"getCompositeManifest",value:function(e,t,n){var i=e.href;return i&&(i=this._resolveUrl(i)),i?(i=f(i,"manifest"),this.getAssetAsType(i,"text",t,n)):n(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+i))}},{key:"getComponentHref",value:function(e,t){var n,i=e._owner;if(!i||!i.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");return i._core&&(n=i._core._getSourceHrefOfComponent(e)),n||this._constructComponentHref(i.compositeHref,e,t)}},{key:"getComponentRenditionHref",value:function(e,t,n,i,o){var r=e._owner;if(!r||!r.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(r._core&&r._core._getSourceHrefOfComponent(e))throw new u(u.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(r.compositeHref,e,t,n,i,o)}},{key:"_constructComponentHref",value:function(e,t,n){var i=t.absolutePath.slice(1),o=f(this._resolveUrl(e),i);return o&&void 0!==n&&(this._hrefUsesContentApis(e)?o+="/version/"+n:o+="?version="+n),o}},{key:"_constructComponentRenditionHref",value:function(e,t,n,i,o,r){var a,s,c=t.absolutePath.slice(1),l=h.parseURI(e).path;if("/content/2/"===l.slice(0,"/content/2/".length)){var f=_[i];if(!f)throw new u(u.INVALID_PARAMS,"Unsupported rendition media type: "+i);if(!((a=p.exec(l))&&a.length>0))throw new u(u.INVALID_PARAMS,"Failed to parse composite href: "+e);s=this._resolveUrl(h.appendPathElements(a[0],"rendition",c,"version",n,"format",f,"dimension",o,"size",String(r)))}else{if(!((a=d.exec(l))&&a.length>0))throw new u(u.INVALID_PARAMS,"Failed to parse composite href: "+e);s=this._resolveUrl(h.appendPathElements(a[0],"rendition",o,String(r),c)+"?version="+n)}return s}},{key:"_hrefUsesContentApis",value:function(e){return"/content/2/"===h.parseURI(e).path.slice(0,"/content/2/".length)}}])&&r(n.prototype,i),t}(l);e.exports=m},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=n(3),s=n(1),c=/(.*)\.TEMP_[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,l=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._config=n,this._services=t}var t,n;return t=e,(n=[{key:"_uuid",value:function(){return this._services.uuid()}},{key:"_getTempPath",value:function(e){return e+".TEMP_"+this._uuid()}},{key:"_stripTempSuffix",value:function(e){var t=e.match(c);return t&&t[1]?t[1]:e}},{key:"_fsApply",value:function(e){for(var t=this,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];var a=i.find((function(e){return"function"==typeof e})),s=i.slice(0,i.indexOf(a)),c=i.indexOf(a)===i.length-1?0:i[i.length-1],l=function(n){if(n&&"EPERM"===n.code&&c<t._config.FS_MAX_RETRIES)setTimeout((function(){t._fsApply.apply(t,[e].concat(o(s),[a,c+1]))}),t._config.FS_RETRY_INTERVAL);else{for(var i=arguments.length,r=new Array(i>1?i-1:0),l=1;l<i;l++)r[l-1]=arguments[l];a.apply(void 0,[n].concat(r))}};this._fs[e].apply(this._fs,s.concat(l))}},{key:"ensurePathExists",value:function(e,t){var n=this;!function e(t,i,o){var r=i.slice(0,t).join(n._pathSep),a=function(){t<i.length?e(t+1,i,o):o(null)};n._fs.exists(r,(function(e){return e?a():n._fs.mkdir(r,a)}))}(2,e.replace(/\\/g,this._pathSep).split(this._pathSep),t)}},{key:"copyFile",value:function(e,t,n){var i=this,o=this._getTempPath(t);this._fsApply("copyFile",e,o,(function(e){e?n(e):i._fsApply("rename",o,t,n)}))}},{key:"getAvailablePath",value:function(e,t,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=t.lastIndexOf(".");r=-1===r?t.length:r;var a=t.substring(0,r),s=t.substring(r+1),c="".concat(o?" (".concat(o,")"):"").concat(s?".".concat(s):""),l=255-this._getTempPath("").length-c.length,u=a.substr(0,l);u[u.length-1].charCodeAt(0)>=55296&&u[u.length-1].charCodeAt(0)<=56319&&(u=u.substr(0,u.length-1));var h="".concat(e).concat(u).concat(c);this.statFile(h,(function(r){r&&r.underlyingError&&"ENOENT"===r.underlyingError.code?n(null,h):r?n(r):i.getAvailablePath(e,t,n,o+1)}))}},{key:"rename",value:function(e,t,n){this._fsApply("rename",e,t,n)}},{key:"deleteFile",value:function(e,t){this._fsApply("unlink",e,t)}},{key:"normaliseTempFileName",value:function(e){return this._stripTempSuffix(e)}},{key:"getFileExtension",value:function(e){var t=e&&e.replace(/^.*[\\/]/,""),n=t?t.lastIndexOf("."):-1;if(-1!==n)return t.substr(n+1).toLowerCase()}},{key:"recursiveDeleteDirectory",value:function(e,t){var n=this,i=function(e){e&&"ENOENT"===e.code&&(e=null),t&&t(e)};this._fsApply("readdir",e,(function(t,o){if(t)i(t);else if(o&&0!==o.length){var r=null,a=0,s=function(t){t&&"ENOENT"===t.code&&(t=null),r=r||t,++a===o.length&&(r?i(r):n._fs.rmdir(e,i))};o.forEach((function(t){var i=e+n._pathSep+t;n._fsApply("readdir",i,(function(e){e?n._fs.unlink(i,s):n.recursiveDeleteDirectory(i,s)}))}))}else n._fs.rmdir(e,i)}))}},{key:"getUserDir",value:function(e){var t=this._services.getPathSeparator(),n=e.replace(/@/g,"_");return this._config.ROOT_DIR+t+n}},{key:"moveLibrary",value:function(e,t,n){var i=this;if(t!==e.id){var o=e._collection._getCompositeDir(t),r=e._getCompositeDir(),a=e._collection._getRenditionCacheDir(t),s=e._getRenditionCacheDir();this.rename(o,r,(function(t){t?n(t):(e._dcxComposite.path=r,i.rename(a,s,(function(e){return n(e&&"ENOENT"===e.code?null:e)})))}))}else n(null)}},{key:"readLibraryDirectory",value:function(e,t){var n=this,i=e._getTempDir();this.recursiveDeleteDirectory(i,(function(){var i=e._getCompositeDir();n._fsApply("readdir",i,t)}))}},{key:"doesRootDirExist",value:function(e,t){var n=e._getCompositeDir();this._fs.exists(n,(function(e){return t(null,e)}))}},{key:"deleteLibraryFromDisk",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(this._fs){var o=e._getCompositeDir(t),r=e._getRenditionCacheDir(t);this.recursiveDeleteDirectory(o,(function(){return n.recursiveDeleteDirectory(r,i)}))}else i(null)}},{key:"writeJSONData",value:function(e,t,n){var i=this;return new Promise((function(o,r){i.ensurePathExists(e,(function(a){if(a)r(a);else{var s=e+i._services.getPathSeparator()+t,c=s+".TEMP_"+i._uuid();i._fs.writeFile(c,JSON.stringify(n,void 0,2),"utf8",(function(e){e?r(e):i._fsApply("rename",c,s,(function(e){return e?r(e):o(s)}))}))}}))}))}},{key:"readJSONData",value:function(e){var t=this;return new Promise((function(n,o){t._fs.readFile(e,"utf8",(function(e,t){if(e)"ENOENT"===e.code?n():o(e);else try{var r=t&&JSON.parse(t);n("object"===i(r)?r:void 0)}catch(e){o(e)}}))}))}},{key:"statFile",value:function(e,t){this._fs.stat(e,(function(e,n){e?t(a.getFileSystemError(e,"unable to stat file")):t(null,n)}))}},{key:"checkFileSize",value:function(e,t){var n=this;this.statFile(e,(function(e,i){e?t(e):i&&i.size>n._config.MAX_COMPONENT_SIZE?t(new s(s.FILE_TOO_LARGE,"Exceeds maximum file size")):t(null)}))}},{key:"computeSHA",value:function(e){var t=this;return new Promise((function(n,i){var o=t._services.crypto.createHash("sha256");o.setEncoding("hex");var r=t._fs.createReadStream(e);r.on("error",(function(e){return i(e)})),o.on("finish",(function(){return n(o.read())})),r.pipe(o)}))}},{key:"_fs",get:function(){return this._services.fs}},{key:"_pathSep",get:function(){return this._services.getPathSeparator()}}])&&r(t.prototype,n),e}();e.exports=l},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function i(e){if(!e)return{};var t={libraryID:e.id,libraryElementCount:e._elements.length,libraryGroupCount:e._groups?e._groups.length:0};return e.collection.isPublic?t.libraryShared="incoming-public":e.collaboration&&(t.libraryShared=e.collaboration,e.isWritable||(t.libraryShared+="-readonly")),t}function o(e){if(!e)return{};var t=i(e._library);t.elementID=e.id,t.elementType=function(e){if(e.type){var t=e.type.match(/application\/vnd\.adobe\.element\.(.*)\+dcx/);return t&&2===t.length?t[1]:e.type}return null}(e),t.elementGroupIDs=e.getGroups(/.*/).map((function(e){return e.id}));var n=e.getPrimaryRepresentation();if(n){var o=function(e){var t=null;return e.getValues().forEach((function(e){"trackingdata"===e.key&&(t||(t={}),t[e.namespace]=e.value)})),t}(n);o&&(t.trackingData=JSON.stringify(o)),t.elementPrimaryType=n.type}return t}function r(e,t){if(!e)return{};var n=t?{}:i(e._library);return n.groupID=e.id,n.groupClassifierName=e.classifierName,n}function a(e){if(!e)return{};var t={element:function(){return o(e.element)},library:function(){return i(e.library)}}[e.type],n=t?t():{};return n.appCode=e.appCode,n.elementAction=e.id,n}var s=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._analytics=t,this._config=n}var t,s;return t=e,(s=[{key:"_isReportingEnabled",value:function(){return null!==this._analytics&&void 0!==this._analytics}},{key:"reportError",value:function(e){this._isReportingEnabled()&&e&&this._analytics.reportError(e.code+(e.underlyingError?":"+e.underlyingError.code:""))}},{key:"reportCreateLibrary",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("createLibrary",{libraryID:e.id})}},{key:"reportDeleteLibrary",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("deleteLibrary",i(e))}},{key:"reportExportLibrary",value:function(e,t){if(this._isReportingEnabled()){var n=t?i(t):{};e&&(n.error=e.code),this._analytics.reportEvent("exportLibrary",n)}}},{key:"reportImportLibrary",value:function(e,t){if(this._isReportingEnabled()){var n=t?i(t):{};e&&(n.error=e.code),this._analytics.reportEvent("importLibrary",n)}}},{key:"reportCreateElement",value:function(e){this._isReportingEnabled()&&(this._lastUpdatedElement=e,this._lastUpdatedElementOn=Date.now(),this._analytics.reportEvent("createElement",o(e)))}},{key:"reportUpdateElement",value:function(e,t){if(this._isReportingEnabled()){if(e===this._lastUpdatedElement&&Date.now()-this._lastUpdatedElementOn<this._config.ANALYTICS_ELEMENT_UPDATE_THRESHOLD)return;this._lastUpdatedElement=e,this._lastUpdatedElementOn=Date.now();var n=o(e);n.updateType=t?"info":"representation",this._analytics.reportEvent("updateElement",n)}}},{key:"_reportUpdateElementMetadata",value:function(e,t,n){if(this._isReportingEnabled()){var i=o(e);i.updateType=t,n&&Object.assign(i,n),this._analytics.reportEvent("updateElementMetadata",i)}}},{key:"reportSetOrderInGroup",value:function(e,t,n){var i=r(t,!0);i.elementOrderInGroup=e.getOrderInGroup(t),i.removeExistingGroups=n,this._reportUpdateElementMetadata(e,"order",i)}},{key:"reportSetDescription",value:function(e){this._reportUpdateElementMetadata(e,"description")}},{key:"reportUseElement",value:function(e,t,n){if(this._isReportingEnabled()){var i=function(e){if(!e)return{};var t=o(e._element);return t.representationType=e.type,t.representationId=e.id,t}(e);i.opType=t,i.details=n,this._analytics.reportEvent("useElement",i)}}},{key:"reportCheckoutElement",value:function(e,t,n){if(this._isReportingEnabled()){var i=o(e);i.opType=t,i.details=n,this._analytics.reportEvent("checkoutElement",i)}}},{key:"reportDeleteElement",value:function(e,t){if(this._isReportingEnabled()){var n=o(e);n.isPermanent=!!t,this._analytics.reportEvent("deleteElement",n)}}},{key:"reportRestoreElement",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("restoreElement",o(e))}},{key:"reportCopyElement",value:function(e,t){if(this._isReportingEnabled()){this._lastUpdatedElement=e,this._lastUpdatedElementOn=Date.now();var n=o(e);n.oldLibraryID=t._library.id,n.oldElementID=t.id,this._analytics.reportEvent("copyElement",n)}}},{key:"reportMoveElement",value:function(e,t){if(this._isReportingEnabled()){this._lastUpdatedElement=e,this._lastUpdatedElementOn=Date.now();var n=o(e);n.oldLibraryID=t._library.id,n.oldElementID=t.id,this._analytics.reportEvent("moveElement",n)}}},{key:"reportCreateGroup",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("createGroup",r(e))}},{key:"reportUpdateGroup",value:function(e){if(this._isReportingEnabled()){var t=r(e);t.updateType="name",this._analytics.reportEvent("updateGroup",t)}}},{key:"reportUpdateGroupMetadata",value:function(e,t,n){if(this._isReportingEnabled()){var i=r(e);i.updateType=t,n&&Object.assign(i,n),this._analytics.reportEvent("updateGroupMetadata",i)}}},{key:"reportDeleteGroup",value:function(e,t,n){if(this._isReportingEnabled()){var i=r(e);i.includeContents=t,t&&(i.numberElementsInGroup=n),this._analytics.reportEvent("deleteGroup",i)}}},{key:"reportCopyGroup",value:function(e,t,n,i){if(this._isReportingEnabled()){var o=r(e);o.oldLibraryID=t._library.id,o.oldGroupID=t.id,o.includeContents=n,n&&(o.numberElementsInGroup=i),this._analytics.reportEvent("copyGroup",o)}}},{key:"reportMoveGroup",value:function(e,t,n,i){if(this._isReportingEnabled()){var o=r(e);o.oldLibraryID=t._library.id,o.oldGroupID=t.id,o.includeContents=n,n&&(o.numberElementsInGroup=i),this._analytics.reportEvent("moveGroup",o)}}},{key:"reportCollisionElement",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("collisionLibrary",o(e))}},{key:"reportCreateLink",value:function(e,t){if(this._isReportingEnabled()){var n=o(e);n.opType=t,this._analytics.reportEvent("createLink",n)}}},{key:"reportShareElementLink",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("shareElementLink",o(e))}},{key:"reportShareLibraryLink",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("shareLibraryLink",i(e))}},{key:"reportActionInvoked",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("".concat(e.type,"ActionInvoked"),a(e))}},{key:"reportActionSuccessful",value:function(e,t){if(this._isReportingEnabled()){var n=a(e);n.appVersion=t&&t.version,n.appLaunchStatus=t?t.isAlreadyRunning?"Running":"Launched":"Unknown",this._analytics.reportEvent("".concat(e.type,"ActionSuccessful"),n)}}},{key:"reportActionFailed",value:function(e,t){if(this._isReportingEnabled()){var n=a(e);n.error=t?t.code+":"+t.message:"",this._analytics.reportEvent("".concat(e.type,"ActionFailed"),n)}}},{key:"reportUnexpectedState",value:function(e,t){if(this._isReportingEnabled()){var n=i(e);n.details=t,this._analytics.reportEvent("unexpectedState",n)}}},{key:"reportRemoveMissingComponents",value:function(e,t,n){if(this._isReportingEnabled()){var i={libraryID:e,numMissing:t.length,numFixed:n,componentErrors:[]};t.forEach((function(e){var t=e.error,n=t&&t.code,o=t&&t.response&&t.response.statusCode,r=(n||"UNKNOWN_ERROR")+(o?": "+o:"");i.componentErrors.push(r)})),this._analytics.reportEvent("removeMissingComponents",i)}}}])&&n(t.prototype,s),e}();e.exports=s},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var c=n(33),l=n(6),u=n(1),h=function(e){function t(e,n){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(i=r(this,a(t).call(this,e)))._setDCXNode(n),i}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,e),n=t,(i=[{key:"_setDCXNode",value:function(e){this._dcxNode=e,this._deletedLocally=!1}},{key:"_reportRename",value:function(){this._analytics.reportUpdateGroup(this)}},{key:"_toJSON",value:function(){return{id:this.id,classifierName:this.classifierName,name:this.name,order:this.order}}},{key:"classifierName",get:function(){return this._dcxNode.getValue(this._config.CLASSIFIER_KEY)}},{key:"order",get:function(){return this._dcxNode.getValue(this._config.ORDER_KEY)},set:function(e){if(l.checkDeletedState(this),!this.isWritable)throw new u(u.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e)throw new u(u.INVALID_PARAMETER,"order must be a string",this._library.id);this._dcxNode.setValue(this._config.ORDER_KEY,e),this._commitMetadata(),this._analytics.reportUpdateGroupMetadata(this,"order",{groupOrder:e})}},{key:"parent",get:function(){var e=this._dcxNode.getValue(this._config.PARENT_KEY);return this._library.getGroups(this.classifierName).find((function(t){return t.id===e}))},set:function(e){if(l.checkDeletedState(this),!this.isWritable)throw new u(u.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(void 0===e)return this._dcxNode.removeValue(this._config.PARENT_KEY),this._commitMetadata(),void this._analytics.reportUpdateGroupMetadata(this,"parent");if(!(e instanceof t))throw new u(u.INVALID_PARAMETER,"not a valid group",this._library.id);if(e===this)throw new u(u.INVALID_PARAMETER,"group cannot be its own parent",this._library.id);if(e.library!==this.library)throw new u(u.INVALID_PARAMETER,"Cannot set parent to a group that is in a different library.",this._library.id);if(e.classifierName!==this.classifierName)throw new u(u.INVALID_PARAMETER,"Cannot set parent to a group that is in a different classifier.",this._library.id);this._dcxNode.setValue(this._config.PARENT_KEY,e.id),this._commitMetadata(),this._analytics.reportUpdateGroupMetadata(this,"parent",{groupParent:e.id})}},{key:"children",get:function(){var e=this;return this._library.getGroups(this.classifierName).filter((function(t){return t._dcxNode.getValue(e._config.PARENT_KEY)===e.id}))}}])&&o(n.prototype,i),t}(c);e.exports=h},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(33),u=n(65),h=n(1),p=n(66),d=n(9),_=n(6),f=n(67),m=n(35),v=n(3),y=n(4).promisify,g=function(e){function t(e,n){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(i=r(this,s(t).call(this,e)))._renditionFetchLock=new d,i._transactionCount=0,i._setDCXNode(n,!0),i}var n,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(l=[{key:"_setDCXNode",value:function(e,t){var n=this,i={};this._representations&&this._representations.forEach((function(e){i[e.id]=e})),this._dcxNode=e,this._representations=[],this._deletedLocally=!1,this._library._dcxBranch.getChildrenOf(e).forEach((function(e){var t=i[e.id];t?(t._setDCXNode(e),delete i[e.id]):t=new u(n,e),n._representations.push(t)})),this._library._dcxBranch.getComponentsOf(e).forEach((function(e){var t=i[e.id];t?(t._setDCXComponent(e),delete i[e.id]):t=new u(n,void 0,e),n._representations.push(t)})),_.sortRepresentations(this._representations),t||this.library._renditionCache.clearCache(this)}},{key:"_markDeletedLocally",value:function(e){a(s(t.prototype),"_markDeletedLocally",this).call(this,e),this._representations.forEach((function(t){t._markDeletedLocally(e)}))}},{key:"_toJSON",value:function(){var e={id:this.id,name:this.name,type:this.type,description:this.description,representations:this._representations.map((function(e){return e._toJSON()}))};return e.representations.sort((function(e,t){return e.type>t.type?1:e.type<t.type?-1:0})),e}},{key:"_addRepresentation",value:function(e,t){void 0!==t?this._representations.splice(t,0,e):this._representations.push(e)}},{key:"_removeRepresentation",value:function(e){var t=this._representations.indexOf(e);-1!==t&&this._representations.splice(t,1)}},{key:"_validateRelationship",value:function(e){var t=this;if(-1===this._config.VALID_RELATIONS.indexOf(e))throw new h(h.INVALID_PARAMETER,"Unsupported relationship",this._library.id);this._representations.length>0&&"primary"===e&&this._representations.forEach((function(n){if(n!==e&&"primary"===n.relationship)throw new h(h.INVALID_PARAMETER,"Cannot have more than one primary representation",t._library.id)}))}},{key:"_doCreateRepresentation",value:function(e,t,n){var i=this,o=this._library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);if(o.type=e,o.setValue(this._config.RELATIONSHIP_KEY,t),void 0===n){var r=this.representations[this.representations.length-1],a=Math.max(this.representations.length,r?r._getOrder()+1:0);o.setValue(this._config.REPRESENTATION_ORDER_KEY,a)}else o.setValue(this._config.REPRESENTATION_ORDER_KEY,n),this._representations.forEach((function(e,t){if(t>=n){var o=e._getDCXElement(),r=o.getValue(i._config.REPRESENTATION_ORDER_KEY);void 0!==r&&o.setValue(i._config.REPRESENTATION_ORDER_KEY,r+1)}}));var s=new u(this,o);return this._addRepresentation(s,n),s}},{key:"_updateTimestampOnRemove",value:function(e){var t=e||Date.now();this._dcxNode.setValue(this._config.REMOVED_KEY,t),this._setEventData("REMOVED",t)}},{key:"_updateTimestampOnRestore",value:function(){this._dcxNode.removeValue(this._config.REMOVED_KEY),this._clearEventData("REMOVED")}},{key:"_ensureRemovedDataValid",value:function(e){this.removed&&!this._getEventData("REMOVED",!0)?e?this._setEventData("REMOVED",this.removed):this._clearEventData("REMOVED"):this.removed||this._clearEventData("REMOVED")}},{key:"_commit",value:function(){this._forEachRepresentation((function(e){return e._clearCachedExternalLink(!0)})),this._updateName(),a(s(t.prototype),"_commit",this).call(this),this._analytics.reportUpdateElement(this,!1)}},{key:"_reportRename",value:function(){this._analytics.reportUpdateElement(this,!0)}},{key:"_getName",value:function(){return this.isAutoNamed?f.getGeneratedName(this):a(s(t.prototype),"_getName",this).call(this)}},{key:"_updateName",value:function(){var e=this._dcxNode.name;if(this.isAutoNamed){var t=f.getGeneratedName(this);t!==e&&(this._dcxNode.name=t,this._dcxNode.setValue(this._config.AUTO_NAMED_KEY,t))}}},{key:"_wrapOperation",value:function(e,t){var n=this;return this._library._wrapOperation((function(){var i=n._library._wrapOperation(e,t);return n._updateModifiedTime(),n._listenerManager.notify("change"),i}))}},{key:"_getMissingLocalComponents",value:function(){return this._representations.reduce((function(e,t){return e.concat(t._getMissingLocalComponents())}),[])}},{key:"_forEachRepresentation",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.representations;n.forEach((function(n){e(n),t._forEachRepresentation(e,n.children)}))}},{key:"_shouldGCLocalData",value:function(){var e=Date.now();return this.removed&&e-this.removed>=this._config.REMOVED_ELEMENTS_CACHE_TIMEOUT}},{key:"_stripObsoleteGroupsData",value:function(e){var t=this,n=this._dcxNode.getValue(this._config.GROUPS_KEY);if(n){var i=(e=e||this._config.DEFAULT_GROUP_CLASSIFIER)+"#",o=!1;Object.keys(n).forEach((function(e){if(e.startsWith(i)){var r=e.substring(i.length);t.library.getGroupById(r)||(delete n[e],o=!0)}})),o&&this._dcxNode.setValue(this._config.GROUPS_KEY,n)}}},{key:"_prefetchRenditions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._services.hasFileSystem())return Promise.resolve();var n=this._config.RENDITION_SIZES||{},i=n[this.type]||n["*"]||[],o=y(this.getThumbnailPath.bind(this)),r=i.map((function(e){return o(e)}));this._config.shouldPrefetchFullRendition(this)&&r.push(o(void 0)),this._forEachRepresentation((function(t){if(e._config.shouldPrefetchExternalLink(t)){var n=y(t.getContentPath.bind(t));r.push(n())}else if(t.isExternalLink){var i=y(t.testExternalLink.bind(t));r.push(i())}}));var a=Promise.all(r);return t?a:a.catch((function(){}))}},{key:"_getRenditionCandidate",value:function(e){var t,n=0;if("vector"===e&&this.supportsVectorThumbnail())return this.getPrimaryRepresentation();for(var i=0;i<this._representations.length;i++){var o=this._representations[i],r=Math.max(o.width||0,o.height||0),a=o.isFullSize?Number.POSITIVE_INFINITY:r,s="primary"===o.relationship,c="rendition"===o.relationship;if((!t||o.isPreferredThumbnail&&!t.isPreferredThumbnail||s&&"primary"!==t.relationship||c&&"primary"!==t.relationship&&"rendition"!==t.relationship||c&&"rendition"===t.relationship&&a>n)&&m.canComputeRendition(o)&&(t=o,n=a),c&&"image/png"===o.type&&e&&r===e)break}return t}},{key:"_setRenditionCache",value:function(e,t,n,i,o){var r=this;this.library._renditionCache.setCache(this,e,t,n).then((function(e){i&&r._storageInterface.notifyDownloadRendition(r),o(null,e)}),o)}},{key:"_doSetOrderInGroup",value:function(e,t,n){var i=this._dcxNode.getValue(this._config.GROUPS_KEY)||{},o=e.classifierName+"#"+e.id;n&&Object.keys(i).forEach((function(t){t.startsWith(e.classifierName+"#")&&delete i[t]})),void 0===t&&i[o]&&delete i[o],void 0!==t&&(i[o]={order:t}),this._dcxNode.setValue(this._config.GROUPS_KEY,i)}},{key:"_getActions",value:function(e){var t=this.getPrimaryRepresentation();if(!t)return[];if(this.library.documentType){var n=this._config.DOCUMENT_LIBRARY_ACTION_PRODUCT_MAP,i=n.types[this.library.documentType]||[];return this._constructActions(e,i,n,p)}var o=this._config.ELEMENT_ACTION_PRODUCT_MAP,r=(o.types[this.type]||{})[t.type]||[];return this._constructActions(e,r,o,p)}},{key:"beginOperation",value:function(){if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this.id);this._transactionCount++,this._library._beginOperation()}},{key:"endOperation",value:function(e){if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this.id);this._transactionCount>0&&(this._transactionCount--,this._library._endOperation()),e&&this._library._waitForCommit(e,!0)}},{key:"createRepresentation",value:function(e,t,n,i){var o=this;if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation((function(){if(e===o._config.LINK_REPRESENTATION_TYPE)throw new h(h.INVALID_PARAMETER,"Cannot create external link representation directly - use setContentFromURL instead",o._library.id);if(void 0!==n&&(n<0||n>o._representations.length))throw new h(h.INVALID_PARAMETER,"Invalid index",o._library.id);o._validateRelationship(t);var r=o._doCreateRepresentation(e,t,n);return i||o.library._renditionCache.clearCache(o,!0),r}))}},{key:"removeRepresentation",value:function(e){var t=this;if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation((function(){t._removeRepresentation(e),e._dcxComponent?t._library._dcxBranch.removeComponent(e._dcxComponent):t._library._dcxBranch.removeChild(e._dcxNode),t.library._renditionCache.clearCache(t,!0),e._markDeletedLocally(!0)}))}},{key:"removeAllRepresentations",value:function(){var e=this;if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation((function(){for(;e._representations[0];)e.removeRepresentation(e._representations[0])}))}},{key:"getPrimaryRepresentation",value:function(){return this._representations.find((function(e){return"primary"===e.relationship}))}},{key:"getValue",value:function(e,t){if(e===this._config.DL_NAMESPACE)throw new h(h.INVALID_PARAMETER,"Reserved namespace",this._library.id);var n=_.getDCXKey(e,t);return this._dcxNode.getValue(n)}},{key:"getValues",value:function(){return _.getCustomDCXData(this._dcxNode)}},{key:"setValue",value:function(e,t,n){if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e===this._config.DL_NAMESPACE)throw new h(h.INVALID_PARAMETER,"Reserved namespace",this._library.id);var i,o=_.getDCXKey(e,t);try{i=JSON.parse(JSON.stringify(n))}catch(e){throw new h(h.INVALID_PARAMETER,"Value cannot be serialized to JSON",this._library.id)}this._dcxNode.setValue(o,i),this._commit()}},{key:"removeValue",value:function(e,t){if(e===this._config.DL_NAMESPACE)throw new h(h.INVALID_PARAMETER,"Reserved namespace",this.id);var n=_.getDCXKey(e,t);this._dcxNode.removeValue(n)}},{key:"getThumbnailURL",value:function(e,t){var n=this;_.checkDeletedState(this,t)||this._library._waitForCommit((function(){if(!_.checkDeletedState(n,t)){var i=n._getRenditionCandidate(e);i?n._library._collection._syncManager.renditions.getURL(i,e,t):t(new h(h.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id))}}),!0)}},{key:"getAuthenticatedThumbnailURL",value:function(e,t){var n=this;this.getThumbnailURL(e,(function(e,i){e?t(e):n._library._collection._syncManager.appendAccessTokenToURL(i,t)}))}},{key:"getThumbnailPath",value:function(e,t){var n=this;this._services.hasFileSystem()?_.checkDeletedState(this,t)||this._library._waitForCommit((function(){if(!_.checkDeletedState(n,t))if(n._config.SHARED_LOCAL_STORAGE)n._storageInterface.getRenditionPath(n,e,t);else{var i=function(e,i){n._renditionFetchLock.release(),t(e,i)};n._renditionFetchLock.obtain((function(){if(!_.checkDeletedState(n,i)){var t=n.library._renditionCache.getCache(n,e);if(t)i(null,t);else{var o=n._getRenditionCandidate(e);if(o){if("rendition"===o.relationship&&"image/png"===o.type&&e&&Math.max(o.width||0,o.height||0)===e)return void o.getContentPath(i);var r=n._library._collection._syncManager,a=n.modified,s=function(t,o){n.modified>a?i(new h(h.STALE_THUMBNAIL,"element changed before the rendition was received",n._library.id,t)):_.checkDeletedState(n,i)||(t?i(new h(h.THUMBNAIL_NOT_AVAILABLE,"error generating thumbnail",n._library.id,t)):n._setRenditionCache(e,o,!0,!0,i))};n._services.hasRenditionGenerator()&&e&&"vector"!==e?o.getContentPath((function(t,i){if(!t&&i){var a=o.element.library.collection._getTempDir()+n._services.getPathSeparator()+n._services.uuid()+".png";n._services.renditionGenerator(i,a,e,(function(t){t?r.renditions.download(o,e,s):s(null,a)}))}else r.renditions.download(o,e,s)})):r.renditions.download(o,e,s)}else i(new h(h.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id))}}}))}}),!0):t(new h(h.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))}},{key:"getCachedThumbnailPath",value:function(e){return this.library._renditionCache.getCache(this,e)}},{key:"getThumbnailContent",value:function(e,t,n){var i=this,o=this._services.fs;this._services.hasFileSystem()?_.checkDeletedState(this,n)||_.checkEncoding(t,["utf8","ascii","base64","buffer"],n)&&this.getThumbnailPath(e,(function(e,r){if(!e&&r){if(!_.checkDeletedState(i,n)){var a=function(e,t){e&&(e=v.getCommitError(e,i._library.id,"error reading content from disk")),n(e,t)};"buffer"===t?o.readFile(r,a):o.readFile(r,t,a)}}else n(e)})):n(new h(h.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))}},{key:"setThumbnailCache",value:function(e,t,n){"string"==typeof t?this._services.hasFileSystem()?_.checkDeletedState(this,n)||this._setRenditionCache(e,t,!1,!1,n):n(new h(h.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id)):n(new h(h.INVALID_PARAMETER,"path must be a string",this._library.id))}},{key:"supportsVectorThumbnail",value:function(){var e=this.getPrimaryRepresentation();return!!e&&this._config.VECTOR_RENDITION_ELEMENT_TYPES.indexOf(e.type)>-1}},{key:"getActions",value:function(e){if(!this._config.SHARED_LOCAL_STORAGE)throw new h(h.NOT_SUPPORTED,"getActions() not supported without shared local storage");if(e&&-1===this._config.ELEMENT_ACTIONS.indexOf(e))throw new h(h.INVALID_PARAMETER,"Unknown id supplied. Potential ids are",this._config.ELEMENT_ACTIONS.join(", "));return this._getActions(e)}},{key:"getGroups",value:function(e){var t=this;e=e||this._config.DEFAULT_GROUP_CLASSIFIER;var n=this._dcxNode.getValue(this._config.GROUPS_KEY);if(!n)return[];var i=Object.keys(n);return this.library.getGroups(e).filter((function(e){return void 0!==t.getOrderInGroup(e)})).sort((function(e,t){var n=i.indexOf(e.classifierName+"#"+e.id),o=i.indexOf(t.classifierName+"#"+t.id);return n===o?0:n<o?-1:1}))}},{key:"getOrderInGroup",value:function(e){if(!e)throw new h(h.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library===this.library){var t=this._dcxNode.getValue(this._config.GROUPS_KEY)||{},n=e.classifierName+"#"+e.id;return t[n]&&t[n].order}}},{key:"setOrderInGroup",value:function(e,t,n){if(n=!1!==n,_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e)throw new h(h.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library!==this.library)throw new h(h.INVALID_PARAMETER,"Cannot set element order in a group that is in a different library.",this._library.id);if("string"!=typeof t&&void 0!==t)throw new h(h.INVALID_PARAMETER,"order must be a string",this._library.id);this._doSetOrderInGroup(e,t,n),this._commitMetadata(),this._analytics.reportSetOrderInGroup(this,e,n)}},{key:"getReference",value:function(){return"cloud-asset://"+this._library._collection._syncManager.getElementRefDomain()+this._library._collection._syncManager.getElementRefPath()+"/"+this._library.id+";node="+this.id}},{key:"getRepresentationById",value:function(e){var t;return this._forEachRepresentation((function(n){t||n.id!==e||(t=n)})),t}},{key:"_storageInterface",get:function(){return this._library._storageInterface}},{key:"type",get:function(){return this._dcxNode.type}},{key:"isAutoNamed",get:function(){var e=this._dcxNode.name,t=this._dcxNode.getValue(this._config.AUTO_NAMED_KEY);return!e||e===t}},{key:"tags",get:function(){return this._dcxNode.getValue("tags")||[]},set:function(e){if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e||e.constructor!==Array)throw new h(h.INVALID_PARAMETER,"tags must be an array",this._library.id);if(!e.every((function(e){return"string"==typeof e})))throw new h(h.INVALID_PARAMETER,"tags must be an array of strings",this._library.id);0===e.length?this._dcxNode.removeValue("tags"):this._dcxNode.setValue("tags",e),this._commitMetadata(),this._analytics.reportUpdateElement(this,!0)}},{key:"description",get:function(){return this._dcxNode.getValue(this._config.DESCRIPTION_KEY)||""},set:function(e){if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.setValue(this._config.DESCRIPTION_KEY,e);var t=Date.now();this._setEventData("DESCRIPTION",t),this._commitMetadata(),this._analytics.reportSetDescription(this)}},{key:"descriptionModified",get:function(){return this._getEventData("DESCRIPTION").time||0}},{key:"descriptionModifiedBy",get:function(){return this._getEventData("DESCRIPTION").userId}},{key:"descriptionModifiedContext",get:function(){return this._getEventContext("DESCRIPTION")}},{key:"wasDescriptionModifiedLocally",get:function(){return this._isLocalEvent("DESCRIPTION")}},{key:"removed",get:function(){return this._dcxNode.getValue(this._config.REMOVED_KEY)}},{key:"removedBy",get:function(){return this._getEventData("REMOVED").userId}},{key:"removedContext",get:function(){return this._getEventContext("REMOVED")}},{key:"wasRemovedLocally",get:function(){return this._isLocalEvent("REMOVED")}},{key:"representations",get:function(){return this._representations}},{key:"sourceRef",get:function(){return this._dcxNode.getValue(this._config.SOURCE_REF_KEY)},set:function(e){if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e||!e.startsWith("urn:"))throw new h(h.INVALID_PARAMETER,"sourceRef must be a string and a valid URN",this._library.id);this._dcxNode.setValue(this._config.SOURCE_REF_KEY,e),this._commit()}},{key:"sourceModified",get:function(){return this._dcxNode.getValue(this._config.SOURCE_MODIFIED_KEY)},set:function(e){if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!["string","number"].includes(i(e)))throw new h(h.INVALID_PARAMETER,"sourceModified must be a string or a number",this._library.id);this._dcxNode.setValue(this._config.SOURCE_MODIFIED_KEY,e),this._commit()}},{key:"dependencies",get:function(){var e=this._dcxNode.getValue(this._config.DEPENDENCIES_KEY);return e?this.library.elements.filter((function(t){return e.includes(t.id)})):[]},set:function(e){var n=this;if(_.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!Array.isArray(e)||!e.every((function(e){return e instanceof t&&e.library===n.library&&!e.removed})))throw new h(h.INVALID_PARAMETER,"dependencies must be an array of elements in this library",this._library.id);var i=[];e.forEach((function(e){var t=e.id;e.id===n.id||i.includes(t)||i.push(t)})),this._dcxNode.setValue(this._config.DEPENDENCIES_KEY,i),this._commit()}},{key:"hasMissingDependencies",get:function(){var e=this._dcxNode.getValue(this._config.DEPENDENCIES_KEY);return!!e&&this.dependencies.length<e.length}}])&&o(n.prototype,l),t}(l);e.exports=g},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(1),r=n(9),a=n(10),s=n(6),c=n(3),l=function(){function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t instanceof e?this._parent=t:this._element=t,n?this._setDCXNode(n):this._setDCXComponent(i),this._lock=new r,this._pendingDownloadCallbacks=[]}var t,n;return t=e,(n=[{key:"_setDCXNode",value:function(t){var n=this,i={};this._children&&this._children.forEach((function(e){i[e.id]=e})),this._dcxNode=t,delete this._dcxComponent,this._deletedLocally=!1,this._children=[],this.element.library._dcxBranch.getChildrenOf(t).forEach((function(t){var o=i[t.id];o?(o._setDCXNode(t),delete i[t.id]):o=new e(n,t),n._children.push(o)})),this.element.library._dcxBranch.getComponentsOf(t).forEach((function(t){var o=i[t.id];o?(o._setDCXComponent(t),delete i[t.id]):o=new e(n,void 0,t),n._children.push(o)}))}},{key:"_setDCXComponent",value:function(e,t){this._dcxComponent=e,delete this._dcxNode,this._children=[],t||(this._deletedLocally=!1)}},{key:"_markDeletedLocally",value:function(e){this._deletedLocally=e}},{key:"_toJSON",value:function(){var e={id:this.id,type:this.type,relationship:this.relationship};return this._services.hasFileSystem()&&(e._componentPath=this._getComponentPath()),e}},{key:"_getOrder",value:function(){return this._getDCXElement().getValue(this._config.REPRESENTATION_ORDER_KEY)||0}},{key:"_setComponentInBrowser",value:function(e,t,n){var i=this;this.element._library._collection._syncManager.uploadNewComponentForRepresentation(e,t,this,(function(e,t){s.checkDeletedState(i,n)||e?n(e):(s.copyCustomDCXData(i._dcxNode,t),i.element._library._dcxBranch.removeChild(i._dcxNode),i._setDCXComponent(t,!0),i._commit(),n(null))}))}},{key:"_setComponentFromPath",value:function(e,t,n,i){var o=this,r=e&&this._services.getFileNameFromPath(e),a=this._services.fileUtils.getFileExtension(r),c=this.id+"."+a;this._services.fileUtils.checkFileSize(e,(function(a){a?i(a):o._storageInterface.getImageDimensions(e,(function(a){o._storageInterface.notifyStartWrite(o.element._library,[],(function(){var l=o.element._library._dcxBranch,u=o._parent?o._parent._dcxNode:o._element._dcxNode;l.addComponent(r,o.type,o.relationship,c,e,n,void 0,u,o.id,(function(e,n){s.checkDeletedState(o,i)||(e?i(e):(s.copyCustomDCXData(o._dcxNode,n),l.removeChild(o._dcxNode),o._setDCXComponent(n,!0),a&&(n.setValue("width",a.width),n.setValue("height",a.height)),t&&n.setValue(o._config.SHA_KEY,t),o._commit(),i(null)))}))}))}))}))}},{key:"_setComponent",value:function(e,t,n,i){var o,r=this,l=this._services.fs,u=function(e){s.checkDeletedState(r,i)||(e?i(c.getCommitError(e,r.element._library.id,"error writing representation contents")):r._setComponentFromPath(o,void 0,!1,i))},h=this.element.library.collection._getTempDir();this._services.fileUtils.ensurePathExists(h,(function(p){if(!s.checkDeletedState(r,i))if(p)i(c.getCommitError(p,r.element._library.id,"error creating temp directory"));else{if(!n){var d=a.getExtensions(r.type)[0];n=r.id+"."+d}o=h+r._services.getPathSeparator()+n,"buffer"===t?l.writeFile(o,e,u):l.writeFile(o,e,t,u)}}))}},{key:"_getCurrentComponentPath",value:function(){if(this._dcxComponent)return this.element._library._dcxBranch.assetOfComponent(this._dcxComponent)}},{key:"_getComponentPath",value:function(e,t){var n=this;if(!e)return this._getCurrentComponentPath();if(this.isExternalLink)return this.element.library.collection._externalLinkCache.getExternalLink(this).then((function(t){return e(null,t)}),e);if(this._dcxComponent){var i=this._getCurrentComponentPath();if(i||t)e(null,i);else{var o=this.element._library;o._networkLock.obtain((function(t){t?e(t):s.checkDeletedState(n,e)?o._networkLock.release():(o._setSyncState("downloading"),o._collection._syncManager.downloadRepresentation(n,(function(t){o._networkLock.release(),o._setSyncState(),s.checkDeletedState(n,e)||(t?e(c.getSyncError(t,n.element._library.id)):(o._commit(!0,!0),o._notifyChange(),n._getComponentPath(e,!0)))})))}))}}else{var r=this._getContentFromData();if(r){var a=this.element.library._renditionCache.getCache(this.element,this.id);a?e(null,a):this._generateContentDataFile(r,e)}else e(null)}}},{key:"_getContentFromData",value:function(){if(this._services.hasFileSystem()){var e=this._config.REPRESENTATION_CONTENT_VALUES[this.type];if(e&&e.contentFromData)return this.getValue(e.namespace,e.key)}}},{key:"_setExternalLink",value:function(e,t){if(this._dcxNode.setValue(this._config.LINK_TYPE_KEY,this._dcxNode.type),this._dcxNode.type=this._config.LINK_REPRESENTATION_TYPE,this._dcxNode.setValue(this._config.LINK_URL_KEY,e),t){t=t.replace(/\\/g,"/");var n=this._config.DEFAULT_CONTENT_LOCATIONS.find((function(e){return t.startsWith(e)}));if(n){var i=t.substring(n.length);this._dcxNode.setValue(this._config.LINK_LOCAL_PATH_KEY,i)}return this.element.library.collection._externalLinkCache.ensureExternalLinkCache(e,t)}return Promise.resolve()}},{key:"_clearCachedExternalLink",value:function(e){var t=this.element.library.collection._externalLinkCache;t&&this.isExternalLink&&(!e||t.getCachedError(this))&&(this._config.SHARED_LOCAL_STORAGE?this._storageInterface.clearCachedExternalLink(this):this._config.shouldPrefetchExternalLink(this)?t.getExternalLink(this,!0).catch((function(){})):t.testExternalLink(this,!0).catch((function(){})))}},{key:"_getLinkLocalPaths",value:function(){var e=this._dcxNode&&this._dcxNode.getValue(this._config.LINK_LOCAL_PATH_KEY);return e?this._config.DEFAULT_CONTENT_LOCATIONS.map((function(t){return"".concat(t).concat(e)})):[]}},{key:"_setContentFromPath",value:function(e,t,n){var i=this,o=function(o){var r=o&&i._config.SHA_CACHE[o];if(r){i._dcxNode.setValue(i._config.SHA_KEY,o);var a=function(){i._commit(),n(null)};i._setExternalLink(r,e).then(a,a)}else i._setComponentFromPath(e,o,t,n)};this._storageInterface.computeSHA(e).then(o,(function(){return o()}))}},{key:"_generateContentDataFile",value:function(e,t){var n=this,i=this.element.library.collection._getTempDir(),o=a.getExtensions(this.type)[0];this._services.fileUtils.writeJSONData(i,this.id+"."+o,e).then((function(e){n.element.setThumbnailCache(n.id,e,(function(e,i){n._storageInterface.notifyDownloadRendition(n.element),t(e,i)}))}),(function(e){return t(c.getCommitError(e))}))}},{key:"_getDCXElement",value:function(){return this._dcxComponent||this._dcxNode}},{key:"_commit",value:function(e){e?this.element._commitMetadata():this.element._commit()}},{key:"_getMissingLocalComponents",value:function(){return this._services.hasFileSystem()&&this._dcxComponent&&!this._getCurrentComponentPath()?[this._dcxComponent]:[]}},{key:"jasmineToString",value:function(){return this.toString()}},{key:"toString",value:function(){return JSON.stringify(this._toJSON())}},{key:"isCompatibleType",value:function(e){if(this._dcxComponent){var t=this._services.fileUtils.getFileExtension(this._dcxComponent.path);if(-1===a.getExtensions(e).indexOf(t))return!1}return s.isCompatibleType(e,this.type)}},{key:"getValue",value:function(e,t){if(e===this._config.DL_NAMESPACE)throw new o(o.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var n=s.getDCXKey(e,t);return this._getDCXElement().getValue(n)}},{key:"getValues",value:function(){return s.getCustomDCXData(this._getDCXElement())}},{key:"setValue",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(s.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(e===this._config.DL_NAMESPACE)throw new o(o.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var r,a=s.getDCXKey(e,t);try{r=JSON.parse(JSON.stringify(n))}catch(e){throw new o(o.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.element._library.id)}this._getDCXElement().setValue(a,r),this._commit(i)}},{key:"setContent",value:function(e,t,n,i){if(!s.checkDeletedState(this,i))if(this.isWritable)if(this._dcxComponent||this.isExternalLink)i(new o(o.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else if(this._services.hasFileSystem()){if(!s.checkEncoding(t,["utf8","ascii","base64","buffer"],i))return;this._setComponent(e,t,n,i)}else{if(void 0!==t)return void i(new o(o.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setComponentInBrowser(e,n,i)}else i(new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))}},{key:"setContentFromPath",value:function(e,t,n){"function"==typeof t&&(n=t,t=!1),this._services.hasFileSystem()?s.checkDeletedState(this,n)||(this.isWritable?this._dcxComponent||this.isExternalLink?n(new o(o.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id)):this._setContentFromPath(e,!t,n):n(new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))):n(new o(o.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id))}},{key:"setContentFromURL",value:function(e,t,n,i){var r=this;if(this._services.hasFileSystem()||e){if(!s.checkDeletedState(this,i))if(this.isWritable)if("boolean"==typeof e)if(this._dcxComponent||this.isExternalLink)i(new o(o.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else{if(e)return this._setExternalLink(t),this._commit(),void i(null);var l=this.element.library.collection,u=l._getTempDir();this._storageInterface.downloadURL(l,t,n,u,(function(e,t,n,o){if(e)i(c.getSyncError(e));else if(!s.checkDeletedState(r,i)){var l=r._config.getContentTypeHeader(o&&o.headers);if(l){var u=t+"."+a.getExtensions(l)[0];r._services.fileUtils.rename(t,u,(function(e){e?i(c.getCommitError(e)):r._setComponentFromPath(u,void 0,!1,i)}))}else r._setComponentFromPath(t,void 0,!1,i)}}))}else i(new o(o.INVALID_PARAMETER,"Invalid createLink parameter: must be Boolean",this.element._library.id));else i(new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))}else i(new o(o.NOT_IMPLEMENTED,"not yet implemented setContentFromURL without a filesystem",this.element._library.id))}},{key:"getContentPath",value:function(e){this._services.hasFileSystem()?s.checkDeletedState(this,e)||this._getComponentPath(e):e(new o(o.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id))}},{key:"getCachedContentPath",value:function(){if(this._services.hasFileSystem())return this.isExternalLink?this.element.library.collection._externalLinkCache.getCachedPath(this):this._dcxComponent?this._getCurrentComponentPath()||void 0:this._getContentFromData()&&this.element.library._renditionCache.getCache(this.element,this.id)||void 0}},{key:"getContent",value:function(e,t){var n=this,i=this._services.fs;if(!s.checkDeletedState(this,t))if(this._services.hasFileSystem()){if(!s.checkEncoding(e,["utf8","ascii","base64","buffer"],t))return;this._getComponentPath((function(o,r){if(!o&&r){if(!s.checkDeletedState(n,t)){var a=function(e,i){e&&(e=c.getCommitError(e,n.element._library.id,"error reading content from disk")),t(e,i)};"buffer"===e?i.readFile(r,a):i.readFile(r,e,a)}}else t(o)}))}else{if(!s.checkEncoding(e,["text","blob","arraybuffer"],t))return;if(!this._dcxComponent)return void t(null);this.element._library._collection._syncManager.getContent(this._dcxComponent,e,t)}}},{key:"getContentURL",value:function(){return this.isExternalLink?this._dcxNode.getValue(this._config.LINK_URL_KEY):this._dcxComponent?this.element._library._collection._syncManager.getContentURL(this._dcxComponent):void 0}},{key:"getAuthenticatedContentURL",value:function(e){var t=this.getContentURL();this.element._library._collection._syncManager.appendAccessTokenToURL(t,e)}},{key:"createChild",value:function(t){if(!this._dcxNode)throw new o(o.NOT_ALLOWED,"can't create child on a component representation",this.element.library.id);var n=this.element.library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);n.type=t,n.setValue(this._config.RELATIONSHIP_KEY,this._config.RELATIONSHIP_CHILD);var i=new e(this,n);return this._children.push(i),this._commit(),i}},{key:"removeChild",value:function(e){if(s.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e._parent!==this)throw new o(o.INVALID_PARAMETER,"cannot remove a child that doesn't belong to this representation",this._library.id);e._dcxComponent?this.element.library._dcxBranch.removeComponent(e._dcxComponent):this.element.library._dcxBranch.removeChild(e._dcxNode);var t=this._children.indexOf(e);-1!==t&&this._children.splice(t,1),this._commit()}},{key:"testExternalLink",value:function(e){this.isExternalLink&&this.getContentURL()?this.element.library.collection._externalLinkCache.testExternalLink(this).then((function(){return e(null,!0)}),(function(){return e(null,!1)})):e(new o(o.INVALID_PARAMETER,"Not an external link",this.element._library.id))}},{key:"clearCachedExternalLink",value:function(){if(!this.isExternalLink||!this.getContentURL())throw new o(o.INVALID_PARAMETER,"Not an external link",this.element._library.id);this._clearCachedExternalLink()}},{key:"getCachedExternalLinkError",value:function(){return this.isExternalLink&&this.getContentURL()?this.element.library.collection._externalLinkCache.getCachedError(this):new o(o.INVALID_PARAMETER,"Not an external link",this.element._library.id)}},{key:"getExternalLinkDownloadProgress",value:function(){if(this.isExternalLink)return this.element.library.collection._getExternalLinkDownloadProgress(this)}},{key:"_services",get:function(){return this.element._services}},{key:"_storageInterface",get:function(){return this.element._storageInterface}},{key:"_config",get:function(){return this.element._config}},{key:"id",get:function(){return this._getDCXElement().id}},{key:"element",get:function(){return this._parent?this._parent.element:this._element}},{key:"children",get:function(){return this._children}},{key:"isWritable",get:function(){return this.element.isWritable}},{key:"type",get:function(){var e=this._getDCXElement().type;return e===this._config.LINK_REPRESENTATION_TYPE?this._getDCXElement().getValue(this._config.LINK_TYPE_KEY):e}},{key:"relationship",get:function(){return this._dcxComponent?this._dcxComponent.relationship||this._dcxComponent.getValue(this._config.RELATIONSHIP_KEY):this._dcxNode.getValue(this._config.RELATIONSHIP_KEY)||this._dcxNode.getValue("relationship")},set:function(e){if(this._parent)throw new o(o.NOT_ALLOWED,"you cannot set relationship on child representations",this.element._library.id);this.element._validateRelationship(e,this),this._dcxComponent?this._dcxComponent.relationship=e:this._dcxNode.setValue(this._config.RELATIONSHIP_KEY,e)}},{key:"width",get:function(){return this._dcxComponent?this._dcxComponent.getValue("width"):this._dcxNode.getValue(this._config.WIDTH_KEY)},set:function(e){if(s.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new o(o.INVALID_PARAMETER,"Cannot set width on a representation without contents",this.element._library.id);if("number"!=typeof e||e<0)throw new o(o.INVALID_PARAMETER,"Invalid width",this.element._library.id);this._dcxComponent?this._dcxComponent.setValue("width",e):this._dcxNode.setValue(this._config.WIDTH_KEY,e),this._commit()}},{key:"height",get:function(){return this._dcxComponent?this._dcxComponent.getValue("height"):this._dcxNode.getValue(this._config.HEIGHT_KEY)},set:function(e){if(s.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new o(o.INVALID_PARAMETER,"Cannot set height on a representation without contents",this.element._library.id);if("number"!=typeof e||e<0)throw new o(o.INVALID_PARAMETER,"Invalid height",this.element._library.id);this._dcxComponent?this._dcxComponent.setValue("height",e):this._dcxNode.setValue(this._config.HEIGHT_KEY,e),this._commit()}},{key:"isFullSize",get:function(){return this._getDCXElement().getValue(this._config.IS_FULL_SIZE_KEY)},set:function(e){if(s.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new o(o.INVALID_PARAMETER,"Cannot set isFullSize on a representation without contents",this.element._library.id);if("boolean"!=typeof e)throw new o(o.INVALID_PARAMETER,"Invalid isFullSize",this.element._library.id);this._getDCXElement().setValue(this._config.IS_FULL_SIZE_KEY,e),this._commit()}},{key:"isPreferredThumbnail",get:function(){return this._getDCXElement().getValue(this._config.IS_PREFERRED_THUMBNAIL_KEY)||!1},set:function(e){if(s.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if("boolean"!=typeof e)throw new o(o.INVALID_PARAMETER,"Invalid isPreferredThumbnail",this.element._library.id);this._getDCXElement().setValue(this._config.IS_PREFERRED_THUMBNAIL_KEY,e),this._commit()}},{key:"contentLength",get:function(){if(this.isExternalLink)return this._dcxNode.getValue(this._config.LENGTH_KEY);if(this._dcxComponent){if(void 0===this._dcxComponent.length&&this._services.hasFileSystem()){var e=this._getCurrentComponentPath();try{var t=this._services.fs.statSync(e);return t&&t.size}catch(e){}}return this._dcxComponent.length}},set:function(e){if(!this.isExternalLink)throw new o(o.READ_ONLY,"setContentLength can only be used for an externally-linked representation",this.element._library.id);if("number"!=typeof e||e<0)throw new o(o.INVALID_PARAMETER,"Invalid content length",this.element._library.id);this._dcxNode.setValue(this._config.LENGTH_KEY,e),this._commit()}},{key:"contentHash",get:function(){return this._getDCXElement().getValue(this._config.SHA_KEY)}},{key:"isDeletedLocally",get:function(){return this._deletedLocally}},{key:"isExternalLink",get:function(){return void 0!==this._dcxNode&&this._dcxNode.type===this._config.LINK_REPRESENTATION_TYPE}}])&&i(t.prototype,n),e}();e.exports=l},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments))}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"type",get:function(){return"element"}},{key:"id",get:function(){return this._id}},{key:"element",get:function(){return this._item}}])&&r(n.prototype,i),t}(n(34));e.exports=l},function(e,t,n){var i;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=n(16),a=function(e){return"RGB"===e.mode},s=function(e){return a(e)&&(!e.profileName||"sRGB IEC61966-2.1"===e.profileName)},c=function(e){var t=Array.isArray(e)?e.find(s)||e.find(a):e;return t&&t.value?function(e,t,n){for(var i=(Math.round(e)<<16|Math.round(t)<<8|Math.round(n)).toString(16);i.length<6;)i="0"+i;return"#".concat(i).toUpperCase()}(t.value.r,t.value.g,t.value.b):""},l=function(e,t,n){for(var i="application/vnd.adobe.".concat(t,"+json"),o=0;o<e.representations.length;o++){var r=e.representations[o];if(r.type===i){var a=r.getValue(t,"data");if(a&&(!n||n(a)))return a}}},u=function(e){return function(t){var n=l(t,e);if(n){var i=n.adbeFont&&n.adbeFont.style.toLowerCase();return!i||i.includes("normal")||i.includes("regular")?n.fontFamily:"".concat(n.fontFamily," ").concat(n.adbeFont.style)}}},h=(o(i={},r.COLOR_ELEMENT_TYPE,(function(e){var t=l(e,"color",s)||l(e,"color",a);return c(t)})),o(i,r.CHARACTER_STYLE_ELEMENT_TYPE,u("characterstyle")),o(i,r.PARAGRAPH_STYLE_ELEMENT_TYPE,u("paragraphstyle")),i);e.exports={colorDataToHexString:c,getGeneratedName:function(e){var t=h[e.type];return t?t(e):""}}},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments))}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"type",get:function(){return"library"}},{key:"id",get:function(){return this._id}},{key:"library",get:function(){return this._item}}])&&r(n.prototype,i),t}(n(34));e.exports=l},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(36),u="renditions",h=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=r(this,s(t).call(this,e.collection._apiRoot,e._getRenditionCacheDir())))._library=e,n._pendingSetCache=[],n}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"getCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"full",n=this._getCache([u,e.id,t]);return this._getFilePath(n)}},{key:"setCache",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"full",i=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this._config.SHARED_LOCAL_STORAGE?this._requestSetCache(e.id,n,i):this._doTransaction((function(){return t._setCache([u,e.id,n],i,o)}))}},{key:"clearCache",value:function(e,t){var n=this,i=this._getCache([u,e.id]);return i?(t&&this._config.SHARED_LOCAL_STORAGE&&this._storageInterface.supportsClearRenditionCache()&&Object.keys(i).forEach((function(t){return n._requestSetCache(e.id,t,"CLEAR")})),this._clearCache(e)):Promise.resolve()}},{key:"copyCache",value:function(e,t){var n=this;return this._config.SHARED_LOCAL_STORAGE?(this._copyCache(e,t),Promise.resolve()):this._doTransaction((function(){return n._copyCache(e,t)}))}},{key:"copyFullCache",value:function(e){var t=this;return this._config.SHARED_LOCAL_STORAGE?this._copyFullCache(e):this._doTransaction((function(){return t._copyFullCache(e)}))}},{key:"serializeCache",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,i={},o=function(o){i[o.id]=e.serializeElementCache(o,t,n)};return this._library.elements.forEach(o),this._library.removedElements.forEach(o),i}},{key:"serializeElementCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,i=Object.assign({},this._cache.renditions&&this._cache.renditions[e.id]||{});return t&&this._convertToAbsolutePaths(i),this._addExternalLinksToElementCache(i,e,t,n),i}},{key:"replaceCache",value:function(e){var t,n,i;this._cache=(i=e,(n=u)in(t={})?Object.defineProperty(t,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[n]=i,t)}},{key:"replaceElementCache",value:function(e,t){this._cache.renditions=this._cache.renditions||{},this._cache.renditions[e.id]=t}},{key:"checkAndInvalidateRenditions",value:function(e,t){var n,i=this,o=this._getCache([u,e.id])||{};return Object.keys(o).some((function(r){if(Number(r)){var a=i._path.join(i._rootDir,o[r]),s=a&&i._fs.statSync(a);return s&&s.size>t?(i.clearCache(e),n="Invalidating rendition - ".concat(e.id," ").concat(e.name," dimension: ").concat(r," size: ").concat(s.size),!0):void 0}})),n}},{key:"doRequestSetCache",value:function(){var e=this;return this._requestingSetCache=this._pendingSetCache,this._pendingSetCache=[],{data:this._requestingSetCache.map((function(e){return{element:e.element,size:e.size,path:e.path}})),cancel:function(){e._pendingSetCache=e._requestingSetCache.concat(e._pendingSetCache),delete e._requestingSetCache},complete:function(t){return e._completeRequestSetCache(t)}}}},{key:"applyRequestSetCache",value:function(e){var t=this;return this._doTransaction((function(){return t._applyRequestSetCache(e)}))}},{key:"gc",value:function(){var e=this,t={},n=function(e){e._shouldGCLocalData()||(t[e.id]=!0)};this._library.elements.forEach(n),this._library.removedElements.forEach(n);var i=this._cache.renditions||{},o=!1;Object.keys(i).forEach((function(n){t[n]||(e._setCacheEntry([u,n]),o=!0)}));var r=o?this.save():Promise.resolve(),a=this._library.collection._externalLinkCache;return r.then((function(){return a&&a.gc()}))}},{key:"_load",value:function(){var e=this;return a(s(t.prototype),"_load",this).call(this).then((function(){e.serializeCache(!0,!1)}))}},{key:"_gcUnreferencedFiles",value:function(){return this._library._dcxComposite.autoRemoveUnusedLocalFiles?a(s(t.prototype),"_gcUnreferencedFiles",this).call(this):Promise.resolve()}},{key:"_copyCache",value:function(e,t){var n=this,i=e.library._renditionCache,o=i._getCache([u,e.id])||{},r=Object.keys(o).map((function(r){var a=i._getFilePath(o[r],!0);if(!a)return Promise.resolve();var s=e.getRepresentationById(r);if(s&&!t.getRepresentationById(r)){var c=e.representations.indexOf(s);c>=0&&c<t.representations.length&&(r=t.representations[c].id)}return i._isPath(a)?n._config.SHARED_LOCAL_STORAGE?n._requestSetCache(t.id,r,a):n._setCache([u,t.id,r],a):Promise.resolve(n._setCacheEntry([u,t.id,r],a))}));return Promise.all(r)}},{key:"_copyFullCache",value:function(e){var t=this;return Promise.all(e.elements.map((function(e){var n=t._library.getElementById(e.id);return n?t._copyCache(e,n):Promise.resolve()})))}},{key:"_requestSetCache",value:function(e,t,n){var i=this;return new Promise((function(o,r){i._pendingSetCache=i._pendingSetCache.filter((function(n){return!(n.element===e&&n.size===t&&"CLEAR"===n.path)})),i._pendingSetCache.push({element:e,size:t,path:n,callback:function(e,t){return e?r(e):o(t)}})}))}},{key:"_applyRequestSetCache",value:function(e){var t=this,n=e.map((function(e){var n=e.element,i=e.size,o=e.path;return"CLEAR"===o?(t._setCacheEntry([u,n,i]),Promise.resolve()):t._setCache([u,n,i],o)}));return Promise.all(n)}},{key:"_completeRequestSetCache",value:function(e){var t=this,n={};return e.forEach((function(e,i){var o=t._requestingSetCache[i],r=t._library.getElementById(o.element);if(o&&r&&e&&0===e.indexOf(t._rootDir)){var a=e.substring(t._rootDir.length+1);t._setCacheEntry([u,o.element,o.size],a),n[r.id]=r}o&&o.callback(null,e)})),delete this._requestingSetCache,Object.keys(n).map((function(e){return n[e]}))}},{key:"_clearCache",value:function(e,t){var n=t?[u,e.id,t]:[u,e.id];return this._setCacheEntry(n),this.save()}},{key:"_convertToAbsolutePaths",value:function(e){var t=this;Object.keys(e).forEach((function(n){var i=e[n];e[n]=t._isPath(i)?t._path.join(t._rootDir,i):i}))}},{key:"_legacyGetCacheEntry",value:function(e){var t=this._getCache([u,e.element.id,e.id]);return this._getFilePath(t,!0)}},{key:"_legacyClearCacheEntry",value:function(e){var t=[u,e.element.id,e.id];this._getCache(t)&&(this._setCacheEntry(t),this.save())}},{key:"_addExternalLinksToElementCache",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3?arguments[3]:void 0;e=e||{};var r=this._library.collection._externalLinkCache;t._forEachRepresentation((function(t){if(t.isExternalLink&&!e[t.id]){var a=r._getCacheEntry(t);a&&(e[t.id]=!i&&a.startsWith(r._rootDir)?n._path.relative(n._rootDir,a):a,r._notifyDownloadRendition(t,o))}}))}}])&&o(n.prototype,i),t}(l);e.exports=h},function(e,t,n){var i=n(3),o=n(4).promisify,r=function(e,t){var n=e[t].bind(e);return function(){return o(n).apply(void 0,arguments).catch((function(e){return Promise.reject(i.getCommitError(e))}))}};e.exports=function(e,t){return{stat:function(t){return r(e,"stat")(t)},statSync:function(t){try{return e.statSync(t)}catch(e){}},unlink:function(t){return r(e,"unlink")(t)},readdir:function(t){return r(e,"readdir")(t)},rename:function(e,n){return r(t,"rename")(e,n)},copy:function(e,n){return r(t,"copyFile")(e,n)},ensureDir:function(e){return r(t,"ensurePathExists")(e)},remove:function(e){var n=this;return this.stat(e).then((function(i){return i&&i.isDirectory()?r(t,"recursiveDeleteDirectory")(e):n.unlink(e)}))}}}},function(e,t){e.exports=function(e){return{join:function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return n.join(e)},relative:function(t,n){for(var i=t.replace(/\\/g,e).split(e),o=n.replace(/\\/g,e).split(e);i[0]===o[0];)i.shift(),o.shift();return new Array(i.length).fill("..").concat(o).join(e)}}}},function(e,t,n){function i(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,r){var a=e.apply(t,n);function s(e){i(a,o,r,s,c,"next",e)}function c(e){i(a,o,r,s,c,"throw",e)}s(void 0)}))}}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=n(27),s=n(2),c=n(0),l=n(1),u=n(6),h=n(10),p=n(73),d=n(74),_=n(75),f=n(76),m=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._apiRoot=t,this._userId=n.USER_ID,this._isPublic=n.IS_PUBLIC,this._storageHost=n.STORAGE_HOSTNAME,this._storageHostRegex=n.STORAGE_HOSTNAME_REGEX,this._platformHost=n.PLATFORM_HOSTNAME,this._isACP=f.isACPHost(n.STORAGE_HOSTNAME),this._ccLibraryHost=n.CC_LIBRARY_SERVICE_HOSTNAME,this._invitationsHost=n.INVITATIONS_HOSTNAME,this._apiKey=this._config.STORAGE_API_KEY,this._XHR=n.XHR,this._requiresCommunitySession=n.REQUIRES_COMMUNITY_SESSION,this._getAccessToken=n.getAccessToken,this._httpServices=[],this._storageService=this._createStorageSession(this.getStorageHost(),!0),this._storageServices={},this._renditionSync=new d(this,n),this._externalLinkSync=new p(this),this._typekitSync=new _(this,n),this._lastSyncGroupState={},this._hasSetAuthToken=!1,this._authToken=void 0,this._inProgressSyncMap={},this._config.SHARED_LOCAL_STORAGE||this._isPublic||this._updateAuthToken()}var t,n,i,m;return t=e,(n=[{key:"_getCommonRequestHeaders",value:function(){var e={};return this._config.USER_AGENT_HEADER&&(e["User-Agent"]=this._config.USER_AGENT_HEADER),e}},{key:"_setAuthToken",value:function(e){this._hasSetAuthToken=!0,this._authToken=e,this._httpServices.forEach((function(t){e?(t.isActive=!0,t.setAuthToken(e)):t.isActive=!1}))}},{key:"_updateAuthToken",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this._getAccessToken(this._authToken,(function(n,i){!n&&i?e._setAuthToken(i):(n&&n.code===l.ACCESS_DENIED&&e._apiRoot.getLoadedCollections().forEach((function(t){t._syncManager===e&&(t._reportSyncError(n),t._updateSyncState())})),e._setAuthToken()),t(null,i)}))}},{key:"_getAuthToken",value:function(e){this._hasSetAuthToken?e(null,this._authToken):this._updateAuthToken(e)}},{key:"_authHandler",value:function(){this._updateAuthToken()}},{key:"_createStorageSession",value:function(e,t){var n=this._getHttpService(e,t);if(e===this.getStorageHost()){if(this._requiresCommunitySession)return this._services.dcx.createCommunitySession(n,e,this._storageHostRegex);if(this._isACP)return this._services.dcx.createPlatformSession(n,e,this._storageHostRegex,this._platformRootDocument)}return this._services.dcx.createStorageSession(n,e,this._storageHostRegex,this.getPlatformHost())}},{key:"getPlatformSession",value:function(){if(!this._platformSession){var e=this.getPlatformHost(),t=this._getHttpService(e,!0);this._platformSession=this._services.dcx.createPlatformSession(t,e,this._storageHostRegex)}return this._platformSession}},{key:"_getHttpService",value:function(e,t){var n,i=this._isPublic&&e===this.getStorageHost();return t&&this._getAccessToken&&!i?(this._authToken||this._updateAuthToken(),(n=this._services.dcx.createHTTPService(this._authHandler.bind(this))).setAuthToken(this._authToken),this._httpServices.push(n)):n=this._services.dcx.createHTTPService(),n.setTimeout(this._config.NETWORK_TIMEOUT),n.setAdditionalNodeOptions(this._services.getNodeTunnelOptions(e)),(t||i)&&(n.setApiKey(this._apiKey),n.setAdditionalHeaders(this._getCommonRequestHeaders())),this._XHR&&n._forceXhr(this._XHR),n}},{key:"_getStorageSession",value:function(e){var t=s.parseURI(e),n=t.scheme+"://"+t.authority,i=this._config.isAdobeDomain(t.authority);return this._storageServices[n]||(this._storageServices[n]=this._createStorageSession(n,i)),this._storageServices[n]}},{key:"_doJSONRequest",value:function(e,t,n){var i=this._getStorageSession(t),o={"Content-Type":"application/json"};return n=n&&JSON.stringify(n),new Promise((function(r,a){i._service.invoke(e,t,o,n,{responseType:"text"},(function(e,t){if(e)return a(e);var n;if(t.response)try{n=JSON.parse(t.response)}catch(e){return void a(new l(l.TRANSFER_ERROR,"Invalid JSON: ".concat(t.response)))}r({statusCode:t.statusCode,response:n,headers:t.headers})}))}))}},{key:"_isManifestOnly",value:function(){return"manifestOnly"===this._config.SYNC_POLICY||!this._services.hasFileSystem()}},{key:"_pullCompositeComponents",value:function(e,t,n,i,o){if(this._isManifestOnly())o(null);else{var r=a.downloadComponents(e,t,this._storageService,o);this._inProgressSyncMap[i]=r,r.onProgress=function(e,t){0!==t&&n._updateProgress(i,e,t)}}}},{key:"_pullComposite",value:function(e,t,n,i){var o=this;this._inProgressSyncMap[n]=a.pullCompositeManifestOnly(e,this._storageService,(function(e,r){if(!e&&r){var a=r.getChildrenOf().find((function(e){return e.name===o._config.ELEMENTS_NAME})),s=r.getComponentsOf();a&&function e(t,n){n.push.apply(n,function(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}(r.getComponentsOf(t))),r.getChildrenOf(t).forEach((function(t){return e(t,n)}))}(a,s),o._pullCompositeComponents(s,r,t,n,(function(e){return i(e,r)}))}else i(e,r)}))}},{key:"getServerComposites",value:function(e,t){var n=this;if(!e._href)return t(null,[]);var i=this._lastSyncGroupState.etag;this._storageService.getCollection(e._href,i,(function(e,i,o,r){if(e)e.response&&404===e.response.statusCode?t(null,[]):t(e);else{if(!i){var a=Math.max(n._config.DEFAULT_MAX_SYNC_INTERVAL,1e3*n._config.getRetryAfterHeader(r));return n._config.MAX_SYNC_INTERVAL=a,void t(null,[])}n._config.MAX_SYNC_INTERVAL=n._config.DEFAULT_MAX_SYNC_INTERVAL;var s=n._lastSyncGroupState.compositeEtags||{},c={},l=[],h={};(i.children||[]).forEach((function(e){e&&u.validateLibraryId(e.name,!1)&&(e.isUnmodified=e.etag&&s[e.name]===e.etag,l.push(e),h[e.name]=e,c[e.name]=e.etag)})),n._lastSyncGroupState={etag:o,compositeEtags:c},t(null,l,h)}}))}},{key:"deleteAllServerComposites",value:function(e,t){var n=e._href;n?this._storageService.deleteCompositeDirectory({href:n},t):t(null)}},{key:"abortAllDownloads",value:function(){var e=this;Object.keys(this._storageServices).map((function(t){return e._storageServices[t]})).forEach((function(e){return e.abortAll()}))}},{key:"clearSyncGroupCache",value:function(){this._lastSyncGroupState={}}},{key:"doHeadRequest",value:function(e,t){var n;try{n=this._storageService.getCompositeManifestHref(e)}catch(e){return void t(e)}this._storageService.headRequest(n,t)}},{key:"hasCompositeChangedOnServer",value:function(e,t){this.doHeadRequest(e,(function(n,i){if(n)t(!0);else{var o=i&&i.headers&&i.headers.etag,r=e.current&&e.current.manifestEtag;t(o!==r)}}))}},{key:"downloadComponent",value:function(e,t,n){a.downloadComponents([t],e,this._storageService,n)}},{key:"downloadRepresentation",value:function(e,t){var n=e._dcxComponent,i=e.element.library._dcxBranch;this.downloadComponent(i,n,t)}},{key:"abortPushOrPull",value:function(e){this._inProgressSyncMap[e]&&(this._inProgressSyncMap[e].abort(new l(l.TRANSFER_ABORTED,"abort push or pull operation")),delete this._inProgressSyncMap[e])}},{key:"pullLibrary",value:function(e,t){var n=this,i=e._dcxComposite,o=e.collection,r=e.id;if(!r&&i.href){var a=i.href.split("/");r=a&&a[a.length-1]}this._services.log("Started pulling: "+r+(this._isManifestOnly()?" (manifest only)":""));var s=Date.now();o._updateProgress(r),this._pullComposite(i,o,r,(function(e,a){var l=Date.now()-s;n._services.log("Finished pulling: "+r+(e?" ["+e.code+"]":"")+" duration="+l),delete n._inProgressSyncMap[r],o._updateProgress(r),a&&(a=a.copy(),u.ensureBranchDataValid(a)),e&&e.code===c.COMPONENT_DOWNLOAD_ERROR?n.doHeadRequest(i,(function(n,i){if(!n&&i&&200===i.statusCode){var r=u.removeMissingComponents(o,e.pulledBranch.copy(),e.failedComponents);if(r)return void t(null,r)}t(e,a)})):t(e,a)}))}},{key:"pullMissingComponents",value:function(e,t){var n=this,i=e.id,o=e.collection,r=e._getMissingLocalComponents();if(this._isManifestOnly()||0===r.length)t(null);else{e._setSyncState("downloading"),this._services.log("Started pulling missing components: "+i);var a=Date.now();o._updateProgress(i),this._pullCompositeComponents(r,e._dcxBranch,o,i,(function(r){var s=Date.now()-a;n._services.log("Finished pulling missing components: "+i+(r?" ["+r.code+"]":"")+" duration="+s),delete n._inProgressSyncMap[i],o._updateProgress(i),e._setSyncState(),r&&r.code===l.TRANSFER_ABORTED?t(null):t(r)}))}}},{key:"pushLibrary",value:function(e,t,n){var i=this,o=e._dcxComposite,r=e.collection,s=e.id;this._services.log("Started pushing: "+s);var c=Date.now();r._updateProgress(s),this._inProgressSyncMap[s]=a.pushComposite(o,t,this._storageService,(function(e){var t=Date.now()-c;i._services.log("Finished pushing: "+s+(e?" ["+e.code+"]":"")+" duration="+t),delete i._inProgressSyncMap[s],r._updateProgress(s),n(e)})),this._inProgressSyncMap[s].onProgress=function(e,t){0!==t&&r._updateProgress(s,e,t)}}},{key:"pushDeletedLibrary",value:function(e,t,n,i){var o=this,r=e._dcxComposite;if(!r.current||r.current.isBound){if(this._isACP)return this._storageService.discardComposite(r,i);this._services.log("Pushing deleted composite: "+r.id),this.pushLibrary(e,n,(function(t){if(t){if(t.code===c.UNEXPECTED_RESPONSE&&t.response&&404===t.response.statusCode)return void o._storageService.deleteCompositeDirectory(r,i);if(t.code===c.UPDATE_CONFLICT){var n=t;return void o.pullLibrary(e,(function(e){e&&e.code===c.NO_COMPOSITE?o._storageService.deleteCompositeDirectory(r,i):e&&e.code===c.DELETED_COMPOSITE?i(null):i(e||n)}))}}i(t)}))}else i(null)}},{key:"getStorageHost",value:function(){return"https://".concat(this._storageHost)}},{key:"getPlatformHost",value:function(){return this._platformHost&&"https://".concat(this._platformHost)}},{key:"getElementRefDomain",value:function(){return this._requiresCommunitySession?this._config.CP_CLOUD_ID:this._storageHost}},{key:"getElementRefPath",value:function(){return this._config.STORAGE_ASSETS_PATH+this._config.LIBRARY_SYNC_GROUP}},{key:"getElementRefDomainPath",value:function(){return this.getElementRefDomain()+this.getElementRefPath()}},{key:"getCollaborationHost",value:function(){return"https://"+this._collaborationHost}},{key:"getContentURL",value:function(e){return this._storageService.getComponentHref(e,e.version)}},{key:"getContent",value:function(e,t,n){this._storageService.getAssetAsType(this.getContentURL(e),t,{},(function(e,t){return e?n(e):n(null,t)}))}},{key:"appendAccessTokenToURL",value:function(e,t){if(e){var n=this._apiKey;this._getAuthToken((function(i,o){t(null,e+="?api_key="+n+(o?"&user_token="+o:""))}))}else t(null,void 0)}},{key:"updateAccessToken",value:function(e){this._setAuthToken(e)}},{key:"isLoggedIn",value:function(){return this._isPublic||this._httpServices[0].isActive}},{key:"uploadNewComponentForRepresentation",value:function(e,t,n,i){var o=n._element._library._dcxComposite;a.uploadNewComponent(e,n.type,o,n.id,this._storageService,(function(e,r){if(e)i(e);else{var a=t?t.lastIndexOf("."):-1,s=-1!==a&&t.substr(a+1).toLowerCase(),c=n.id+"."+s,l=n._parent?n._parent._dcxNode:n._element._dcxNode,u=o.current.addComponentWithUploadResults(t,n.relationship,c,l,r);i(null,u)}}))}},{key:"uploadNewComponentForLibrary",value:function(e,t,n,i,o,r){var s=o._dcxComposite;a.uploadNewComponent(e,n,s,t,this._storageService,(function(e,o){if(e)r(e);else{var a=h.getExtensions(n)[0],c=t+"."+a,l=s.current.addComponentWithUploadResults(c,i,c,s,o);r(null,l)}}))}},{key:"pushClientTokenInfo",value:function(e,t){var n="https://".concat(this._ccLibraryHost,"/api/v1/client-tokens/").concat(e),i={token:JSON.stringify(t),ttl:300};return this._doJSONRequest("POST",n,i).then((function(e){return 201===e.statusCode}),(function(){return!1}))}},{key:"getBookmarks",value:function(){var e="https://".concat(this._ccLibraryHost,"/api/v1/libraries/bookmarks");return this._doJSONRequest("GET",e).then((function(e){var t=e.statusCode,n=e.response;if(404!==t)return 200!==t?Promise.reject(new l(l.TRANSFER_ERROR,"Unexpected response getting bookmarks: ".concat(t))):n}))}},{key:"createBookmarks",value:function(e){var t="https://".concat(this._ccLibraryHost,"/api/v1/libraries/bookmarks");return this._doJSONRequest("POST",t,e).then((function(e){var t=e.statusCode,n=e.response;return 201!==t?Promise.reject(new l(l.TRANSFER_ERROR,"Unexpected response creating bookmarks: ".concat(t))):n}))}},{key:"removeBookmark",value:function(e){var t="https://".concat(this._ccLibraryHost,"/api/v1/libraries/bookmarks/").concat(e);return this._doJSONRequest("DELETE",t).then((function(e){var t=e.statusCode;if(![200,204,404].includes(t))return Promise.reject(new l(l.TRANSFER_ERROR,"Unexpected response deleting bookmark: ".concat(t)))}))}},{key:"removeAllCollaborators",value:function(e){var t=this;if(!e.collection.isPrivate)return Promise.resolve();var n=e._dcxComposite.href&&encodeURIComponent(e._dcxComposite.href),i="https://".concat(this._invitationsHost,"/api/v3/share/").concat(n);return this._doJSONRequest("GET",i).then((function(e){var i=e.response,o=e.statusCode;return[200,204,404].includes(o)?t.removeCollaborators(n,i.collaborators.map((function(e){return e.id})),i.invitations.map((function(e){return e.id}))):Promise.reject(o)})).catch((function(e){return Promise.reject(new l(l.TRANSFER_ERROR,"Unexpected response removing collaborators: ".concat(e)))}))}},{key:"removeCollaborators",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i="https://".concat(this._invitationsHost,"/api/v3/share/").concat(e);return this._doJSONRequest("PATCH",i,{collaborators:t.map((function(e){return{id:e,action:"remove"}})),invitations:n.map((function(e){return{id:e,action:"remove"}}))}).then((function(e){var t=e.statusCode;if(![200,204,404].includes(t))return Promise.reject(t)}))}},{key:"getUserQuota",value:(m=o(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isPublic&&!this._isACP){e.next=2;break}throw new l(l.NOT_ALLOWED,"Cannot get user quota on non-private collection.");case 2:return t="https://".concat(this._storageHost,"/profile/quota"),e.next=5,this._doJSONRequest("GET",t);case 5:if(200===(n=e.sent).statusCode){e.next=8;break}throw new l(l.NETWORK_ERROR,"Could not get quota from storage service. Status: ".concat(n.statusCode));case 8:return e.abrupt("return",n.response);case 9:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"getPublicLibraryAssetId",value:(i=o(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isPublic){e.next=2;break}throw new l(l.NOT_ALLOWED,"getPublicLibraryAssetId is only supported for public collections.");case 2:return e.next=4,this._doJSONRequest("HEAD",t._dcxComposite.href);case 4:return n=e.sent,e.abrupt("return",n&&n.headers&&n.headers["x-resource-urn"]);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_config",get:function(){return this._apiRoot._config}},{key:"_services",get:function(){return this._apiRoot._services}},{key:"_platformRootDocument",get:function(){return this._apiRoot._getCachedRootDocument()}},{key:"typekit",get:function(){return this._typekitSync}},{key:"renditions",get:function(){return this._renditionSync}},{key:"links",get:function(){return this._externalLinkSync}}])&&r(t.prototype,n),e}();e.exports=m},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(11),r=n(0),a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._syncManager=t}var t,n;return t=e,(n=[{key:"_getStorageSession",value:function(e){return this._syncManager._getStorageSession(e)}},{key:"download",value:function(e,t,n,i,a){var s=this,c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this._services.log("download external link: "+e);var l=this._getStorageSession(e),u=n+this._services.getPathSeparator()+this._services.uuid(),h=new o.FileContent(u);t=t||{},this._services.fileUtils.ensurePathExists(n,(function(o){var p;if(o)a(o);else if((p=l.getAssetAsType(e,h,t,(function(o,l,h,d){if(p&&delete p.progress,o&&o.code===r.UNEXPECTED_RESPONSE){var _=o.response&&o.response.statusCode;if(s._services.log("download external link: Unexpected Response "+_+" from "+e),s._config.isRedirect(_)){var f=s._config.getLocationHeader(o.response.headers);if(f&&c<s._config.MAX_REDIRECT_FOLLOW)return s._services.log("download external link: Redirecting to "+f),void s.download(f,t,n,i,a,c+1);o.response.statusCode=404}}a(o,u,h,d)})))&&i){var d,_=0;p.progress=function(e){_+=e,!d&&p.response&&p.response.headers&&(d=s._config.getContentLengthHeader(p.response.headers)),i(_,d||1)},i(0,1)}}))}},{key:"test",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=this._getStorageSession(e);o.headRequest(e,(function(o,r){var a=r?r.statusCode:o;if(n._services.log("test external link: "+e+" -> "+a),r&&n._config.isRedirect(r.statusCode)){var s=n._config.getLocationHeader(r.headers);if(s&&i<n._config.MAX_HEAD_REDIRECT_FOLLOW)return n._services.log("test external link: Redirecting to "+s),void n.test(s,t,i+1);i>0&&(r.statusCode=404)}t(o,r)}))}},{key:"_config",get:function(){return this._syncManager._config}},{key:"_services",get:function(){return this._syncManager._services}}])&&i(t.prototype,n),e}();e.exports=a},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(11),r=n(3),a=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._syncManager=t,this._imageHost=n.CC_IMAGE_HOSTNAME,this._imageXHost=n.CC_IMAGE_X_HOSTNAME,this._renditionStorageService=this._getStorageSession(t.getStorageHost()),this._requiresCommunitySession=n.REQUIRES_COMMUNITY_SESSION}var t,n;return t=e,(n=[{key:"_getStorageSession",value:function(e){return this._syncManager._getStorageSession(e)}},{key:"_downloadRendition",value:function(e,t,n,i,a){var s=this,c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;if(e.isDeletedLocally||e.element.library.isDeletedFromServer)a("Error: representation deleted");else{var l=function(o){return s._downloadRendition(e,t,n,i,a,o)};if(c>0&&"uploading"===e.element.library.syncState)setTimeout((function(){return l(c)}),this._config.RENDITION_RETRY_INTERVAL);else{var u=n+this._services.getPathSeparator()+this._services.uuid()+".png",h=new o.FileContent(u);this._renditionStorageService.getAssetAsType(t,h,i,(function(t){var n=t&&t.response&&t.response.headers,i=function(){return a(t,u)};if(404===r.getErrorStatusCode(t))return s._retry404IfNeeded(e,n,c,l,i);i()}))}}}},{key:"_retry404IfNeeded",value:function(e,t,n,i,o){var r=1e3*this._config.getRetryAfterHeader(t);if(this._config.RENDITION_RETRY_INTERVAL=Math.max(this._config.DEFAULT_RENDITION_RETRY_INTERVAL,r),this._config.RENDITION_404_BACKOFF=Math.max(this._config.DEFAULT_RENDITION_404_BACKOFF,r),n<this._config.RENDITION_MAX_RETRIES)return n++,this._services.log("404 fetching rendition: retrying ("+n+")"),void setTimeout((function(){return i(n)}),this._config.RENDITION_RETRY_INTERVAL);this._services.log("404 fetching rendition: reached maximum retries"),this._services.log("Backing off rendition fetch of "+e.id+" for "+this._config.RENDITION_404_BACKOFF+"ms"),e._lastRendition404=Date.now(),o()}},{key:"_getImageServiceSVGRendition",value:function(e,t,n){var i=this,o=e.element,r="https://"+this._imageHost+"/createagc",a=this._getStorageSession(r),s={inputs:{application_file:{href:o.getReference()}},outputs:{agc:{disposition:"location"}}};if(e.isDeletedLocally||e.element.library.isDeletedFromServer)n("Error: representation deleted");else{var c=function(t){return i._getImageServiceSVGRendition(e,t,n)};a._service.invoke("POST",r,{"Content-Type":"application/vnd.adobe.image-operation+json"},JSON.stringify(s),{responseType:"text"},(function(r,a){if(r||200!==a.statusCode){var s=function(){return n(r||"Image service call failed with: "+a.statusCode)};return a&&404===a.statusCode?i._retry404IfNeeded(e,a&&a.headers,t,c,s):void s()}var l;try{l=JSON.parse(a.response)}catch(e){return n(e)}if(l&&l.outputs&&l.outputs.agc&&l.outputs.agc.location){var u="https://"+i._imageXHost+"/agctosvg",h=i._getStorageSession(u),p={inputs:{href:l.outputs.agc.location}};return h._service.invoke("POST",u,{"Content-Type":"application/vnd.adobe.dwbedrockservice-operation+json"},JSON.stringify(p),{responseType:"text"},(function(e,t){if(e||200!==t.statusCode)return n(e||"Image-x service call failed with: "+t.statusCode);var r=t.response,a=o.library.collection._getTempDir(),s=a+i._services.getPathSeparator()+i._services.uuid()+".svg";i._services.fileUtils.ensurePathExists(a,(function(e){if(e)return n(e);i._services.fs.writeFile(s,r,(function(e){return e?n(e):n(null,s)}))}))}))}n("Invalid image service response")}))}}},{key:"getURL",value:function(e,t,n){if(e._dcxComponent)try{n(null,this._requiresCommunitySession?this._renditionStorageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,"image/png","width",t||"full"):this._renditionStorageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,t||"full"))}catch(e){n(e)}else n("representation must be a component to generate a rendition")}},{key:"download",value:function(e,t,n){var i=this;if(e.element.library.isDeletedFromServer)return this._services.log("Error: Trying to fetch rendition from deleted library."),void n("Error: library deleted");Date.now()-(e._lastRendition404||0)<this._config.RENDITION_404_BACKOFF?n("Error: got 404 on last rendition attempt - backing off"):"vector"===t&&e.element.supportsVectorThumbnail()?function t(){"uploading"!==e.element.library.syncState?i._getImageServiceSVGRendition(e,0,n):setTimeout(t,i._config.RENDITION_RETRY_INTERVAL)}():this.getURL(e,t,(function(t,o){if(t)n(t);else{var r={Accept:"image/png"},a=e.element.library.collection._getTempDir();i._services.fileUtils.ensurePathExists(a,(function(t){t?n(t):i._downloadRendition(e,o,a,r,n)}))}}))}},{key:"_config",get:function(){return this._syncManager._config}},{key:"_services",get:function(){return this._syncManager._services}}])&&i(t.prototype,n),e}();e.exports=a},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var i=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._syncManager=t,this._typekitHost=n.TYPEKIT_HOSTNAME}var t,i;return t=e,(i=[{key:"_getStorageSession",value:function(e){return this._syncManager._getStorageSession(e)}},{key:"getFontData",value:function(e,t){var n="https://"+this._typekitHost+"/v1/variations?include=trial,full,marketplace,purchased&include_marketplace_data=true&purpose=sync";this._getStorageSession(n)._service.invoke("POST",n,null,JSON.stringify(e),{responseType:"text"},(function(e,n){if(e||200!==n.statusCode)return t(e||"Typekit service call failed with: "+n.statusCode);try{t(null,JSON.parse(n.response))}catch(e){t(e)}}))}}])&&n(t.prototype,i),e}();e.exports=i},function(e,t){var n=/^platform-cs(-stage)?(-[a-zA-Z0-9]+)?\.adobe\.io$/;e.exports={isACPHost:function(e){return n.test(e)}}},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(7),r=function(){function e(t,n,i,r,a){var s=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._listenerManager=new o(["progress"],(function(e){return s._collection._services.log(e)})),this._collection=t,this._id=n,this._type=i,this._data=r,this._cancelCallback=a,this._progress=0}var t,n;return t=e,(n=[{key:"_updateProgress",value:function(e){this._progress!==e&&(this._progress=e,this._listenerManager.notify("progress",[this]),this._collection._notifyOperationChange())}},{key:"addProgressListener",value:function(e){this._listenerManager.add("progress",e)}},{key:"removeProgressListener",value:function(e){this._listenerManager.remove("progress",e)}},{key:"cancel",value:function(){this._config.SHARED_LOCAL_STORAGE?this._storageInterface.cancelOperation(this._collection,this._id):this._cancelCallback&&this._cancelCallback()}},{key:"_config",get:function(){return this._collection._config}},{key:"_storageInterface",get:function(){return this._collection._storageInterface}},{key:"id",get:function(){return this._id}},{key:"type",get:function(){return this._type}},{key:"data",get:function(){return this._data}},{key:"progress",get:function(){return this._progress}}])&&i(t.prototype,n),e}();e.exports=r},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){function t(e,n){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(i=r(this,s(t).call(this,"public",e)))._url=n,i}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"toJSON",value:function(){return a(s(t.prototype),"toJSON",this).call(this,{url:this._url})}},{key:"isReferenceTo",value:function(e){return this.url===e._dcxComposite.href}},{key:"url",get:function(){return this._url}}])&&o(n.prototype,i),t}(n(37));e.exports=l},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=function(e){function t(e,n,i){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(o=r(this,s(t).call(this,"collab",e)))._urn=n,o._role=i,o}var n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),n=t,(i=[{key:"toJSON",value:function(){return a(s(t.prototype),"toJSON",this).call(this,{urn:this._urn,role:this._role})}},{key:"isReferenceTo",value:function(e){return e.id===this.id}},{key:"urn",get:function(){return this._urn}},{key:"role",get:function(){return this._role}}])&&o(n.prototype,i),t}(n(37));e.exports=l},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(1),r=n(7),a=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._collection=t,this._listenerManager=new r(["change"],(function(e){return n._services.log(e)})),this._fontsCache={}}var t,n;return t=e,(n=[{key:"_clearCache",value:function(){this._fontsCache={},this._listenerManager.notify("change")}},{key:"addChangeListener",value:function(e){this._listenerManager.add("change",e)}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e)}},{key:"getFontData",value:function(e,t){var n=this,i=this._fontsCache[e];i?t(null,i):this._config.SHARED_LOCAL_STORAGE?this._storageInterface.getFontData(this._collection,e,(function(i,o){o&&(n._fontsCache[e]=o),t(i,o)})):this._collection._syncManager.typekit.getFontData([e],(function(i,r){if(i)t(new o(o.NETWORK_ERROR,"Error occurred while getting font data",null,i));else{var a=r&&r[0];n._fontsCache[e]=a,t(null,a)}}))}},{key:"isSystemFontAvailable",value:function(e,t,n){if(!this._config.SHARED_LOCAL_STORAGE)return n(new o(o.NOT_SUPPORTED,"isSystemFontAvailable() is only supported with shared local storage"));this._storageInterface.isFontAvailable(e,t,n)}},{key:"_config",get:function(){return this._collection._config}},{key:"_services",get:function(){return this._collection._services}},{key:"_storageInterface",get:function(){return this._collection._storageInterface}}])&&i(t.prototype,n),e}();e.exports=a},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,o)}function c(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var r=e.apply(t,n);function a(e){s(r,i,o,a,c,"next",e)}function c(e){s(r,i,o,a,c,"throw",e)}a(void 0)}))}}function l(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function h(e,t,n){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var _=n(39),f=n(1),m=n(82),v=n(38),y=n(2),g=n(8),E=n(4).promisify,O=/@techacct\.adobe\.com$/,A=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=u(this,p(t).call(this,e._config.PLATFORM_DATA_FILENAME,e)))._folders=[],n._root=void 0,n._rootTTL=void 0,n._rootVersion=void 0,n}var n,i,o,a,s,v,A;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}(t,e),n=t,(i=[{key:"load",value:(A=c(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,h(p(t.prototype),"load",this).call(this);case 3:return e.prev=3,e.prev=4,e.next=7,this._loadRootDocument();case 7:this.refreshPlatformFolders(),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(4),this._services.log("Unable to load root document: ".concat(e.t0));case 13:return e.finish(3);case 14:case"end":return e.stop()}}),e,this,[[0,,3,14],[4,10]])}))),function(){return A.apply(this,arguments)})},{key:"_fromJSON",value:function(e){e?(this._folders=e.folders.map((function(e){return new _(e)})),this._root=e.root,this._rootTTL=e.root_ttl,this._rootVersion=e.root_version,this._listenerManager.notify("change")):this._services.log("Unable to load platform data from disk.")}},{key:"_toJSON",value:function(){return{folders:this._folders.map((function(e){return e.toJSON()})),root:this._root,root_version:this._config.PLATFORM_DATA_VERSION,root_ttl:this._rootTTL}}},{key:"_loadRootDocument",value:(v=c(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=E(this._platformSession.getRootDocument.bind(this._platformSession)),!this._config.SHARED_LOCAL_STORAGE){e.next=3;break}throw new f(f.NOT_ALLOWED,"Cannot access platform session from shared local storage");case 3:if(!(this._root&&Date.now()<this._rootTTL&&this._rootVersion===this._config.PLATFORM_DATA_VERSION)){e.next=5;break}return e.abrupt("return",this._platformSession.setRootDocument(this._root));case 5:return e.next=7,t();case 7:this._root=e.sent,this._rootTTL=Date.now()+this._config.PLATFORM_DATA_TTL,this._save();case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"refreshPlatformFolders",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};if(this._refreshCallbacks=this._refreshCallbacks||[],this._refreshCallbacks.push(t),!this._inRefreshQuietPeriod){var n=function(){var t=e._refreshCallbacks;e._refreshCallbacks=[],t.forEach((function(e){return e()}))};this._inRefreshQuietPeriod=!0,setTimeout((function(){e._inRefreshQuietPeriod=!1,e._refreshCallbacks.length>0&&e._refreshPlatformFolders().finally(n)}),this._config.PLATFORM_FOLDER_REFRESH_INTERVAL),this._refreshPlatformFolders().finally(n)}}},{key:"_refreshPlatformFolders",value:(s=c(regeneratorRuntime.mark((function e(){var t,n,i,o,r,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._config.SHARED_LOCAL_STORAGE){e.next=2;break}return e.abrupt("return",this._storageInterface.refreshPlatformFolders());case 2:return e.next=4,E(this._platformSession.getRepositories.bind(this._platformSession))();case 4:if(t=e.sent,(n=m.extractRepositoryData(t))&&0!==n.length){e.next=9;break}throw this._services.log("Error: User doesn't have a repository"),new f(f.INVALID_DATA,"A type-2 user should always have an organization.");case 9:return i=n[0]&&n[0]["repo:owner"]&&n[0]["repo:owner"].id,e.next=12,this._services._getOrgBetaStatus(i||"no-org");case 12:if(this._isBetaMember=e.sent,!this._isBetaMember||!i){e.next=17;break}this._services.log("Organization is permitted to access beta. ".concat(i)),e.next=22;break;case 17:return this._services.log("Organization is not permitted to access beta. ".concat(i)),this._folders=[],this._save(),this._listenerManager.notify("change"),e.abrupt("return");case 22:return o=this._collection.userId,e.next=25,Promise.all(n.map((function(e){return a._getPlatformFolders(o,e)})));case 25:r=e.sent,this._folders=this._filterFolders(r.flat()).map((function(e){return new _(e)})),this._save(),this._listenerManager.notify("change");case 29:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"_getPlatformFolders",value:(a=c(regeneratorRuntime.mark((function e(t,n){var i,o,a,s,c,l,u,h,p,d=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=E(this._platformSession.getAssets.bind(this._platformSession)),o=E(this._platformSession.getEffectiveACFromLinks.bind(this._platformSession)),a=n["repo:repositoryId"],s=function(e){var t=e.map((function(e){return new Promise((function(t,n){d._platformSession.getEffectiveACFromLinks(e.links,(function(i,o){return i?n(i):t(r({},e,{permissions:o}))}))}))}));return Promise.all(t).then((function(e){var t=e&&e.map((function(e){return e.name}));return d._services.log("Fetched ".concat(e&&e.length," folders: ").concat(t.join(", "))),e}))},e.next=6,i();case 6:if((c=e.sent)&&c.children){e.next=9;break}throw new f("INDEX_ERROR","Bad response from ACP discovery API");case 9:e.prev=9,l=m.getPlatformFoldersFromAssetsResponse(n,c,this._config.PLATFORM_HIDDEN_FOLDERS,this._apiRoot._localisation.getLocale()),u=m.getRootLinksFromAssetsResponse(a,c),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(9),this._services.log("Could not parse platform assets response: ".concat(a)),e.t0;case 18:if(u){e.next=20;break}return e.abrupt("return",s(l));case 20:return e.next=22,o(u);case 22:if(e.sent.includes("write")){e.next=25;break}return e.abrupt("return",s(l));case 25:return e.next=27,this._getFolderAtPath(a,m.TOP_LEVEL_FOLDER_PATH);case 27:return h=e.sent,p=[],h.children.forEach((function(e){m.isVisibleFolder(e,d._config.PLATFORM_HIDDEN_FOLDERS)&&p.push({id:e["repo:assetId"],ownerId:e["storage:assignee"]&&e["storage:assignee"].id,ownerType:e["storage:assignee"]&&e["storage:assignee"].type,ownerName:m.getOwnerName(n,d._apiRoot._localisation.getLocale()),name:e["repo:name"],links:e._links,createdBy:e["repo:createdBy"]})})),e.abrupt("return",s(p));case 31:case"end":return e.stop()}}),e,this,[[9,14]])}))),function(e,t){return a.apply(this,arguments)})},{key:"_getFolderAtPath",value:(o=c(regeneratorRuntime.mark((function e(t,n){var i,o,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=E(this._platformSession.getLinksFromPath.bind(this._platformSession)),o=E(this._platformSession.getCollection.bind(this._platformSession)),e.next=4,i(t,n);case 4:return r=e.sent,a=y.getUrlFromLinks(r,g.ID),e.abrupt("return",o(a,void 0));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"_filterFolders",value:function(e){return e.filter((function(e){var t=e.permissions&&e.permissions.includes("write"),n=e.permissions&&e.permissions.includes("read"),i=e.name&&"everyone"===e.name.toLowerCase(),o=O.test(e.createdBy);return t&&n&&i&&o})).map((function(e){return r({},e,{name:e.ownerName})}))}},{key:"_apiRoot",get:function(){return this._collection._apiRoot}},{key:"_platformSession",get:function(){return this._syncManager.getPlatformSession()}},{key:"folders",get:function(){return this._folders}},{key:"cachedRootDocument",get:function(){return this._root}},{key:"isBetaMember",get:function(){return this._isBetaMember}}])&&l(n.prototype,i),t}(v);e.exports=A},function(e,t,n){var i=n(8),o=n(1),r=/^\/content\/assets\/[^/]+$/,a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n="application/vnd.adobecloud.directory+json"===e["dc:format"],i="ACTIVE"===e["repo:state"],o=e["repo:name"];return n&&i&&!t.includes(o)},s=function(e,t){for(var n=e["dc:title"],i=/^rdf:_/,o=Object.keys(n).filter((function(e){return i.test(e)})),r=t?t.replace("_","-"):"",a="",s=0;s<o.length;s++){if(n[o[s]]["@language"]&&n[o[s]]["@language"].toLowerCase()===r.toLowerCase())return n[o[s]]["@value"];"i-default"===n[o[s]]["@language"]&&(a=n[o[s]]["@value"])}return a||"<org>"};e.exports={extractRepositoryData:function(e){return(e&&e.children||[]).filter((function(e){var t=e._embedded&&e._embedded[i.PRIMARY]&&e._embedded[i.PRIMARY]["repo:owner"];return t&&"org"===t.type})).map((function(e){return e._embedded[i.PRIMARY]}))},getRootLinksFromAssetsResponse:function(e,t){var n=t.children.find((function(t){var n=t&&t._embedded&&t._embedded[i.METADATA];if(n)return"/"===n["repo:path"]&&n["repo:repositoryId"]===e}));return n&&n._embedded[i.METADATA]._links},getPlatformFoldersFromAssetsResponse:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],c=arguments.length>3?arguments[3]:void 0,l=[];return t.children.forEach((function(t){var u=t&&t._embedded&&t._embedded[i.METADATA],h=e["repo:repositoryId"];if(!u)throw new o(o.INVALID_DATA,"Malformed ACP-CS index entry: ".concat(h));var p=a(u,n),d=r.test(u["repo:path"]),_=u["repo:repositoryId"]===h,f=[];p||f.push("Not visible: repo:state=".concat(u["repo:state"]," dc:format=").concat(u["dc:format"])),d||f.push("Not top level: repo:path=".concat(u["repo:path"])),_||f.push("Not in correct repo: repositoryId=".concat(u["repo:repositoryId"]));var m=s(e,c);0===f.length&&l.push({id:u["repo:assetId"],ownerId:u["storage:assignee"]&&u["storage:assignee"].id,ownerType:u["storage:assignee"]&&u["storage:assignee"].type,ownerName:m,name:u["repo:name"],links:u._links,createdBy:u["repo:createdBy"]})})),l},isVisibleFolder:a,getOwnerName:s,TOP_LEVEL_FOLDER_PATH:"/content/assets"}},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var l=n(1),u=n(10),h=n(3),p=n(36),d=n(4).promisify,_={},f=function(e){function t(e,n){var i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var a=e._services.fileUtils.getUserDir(n)+e._services.getPathSeparator()+"links";return(i=o(this,r(t).call(this,e,a)))._userId=n,i._collections=[],i._pendingDownloads={},i._pendingTests={},i._referencedLinks={},i._sentNotifications={},i._sharedStorage={downloadExternalLink:function(e){return d(i._storageInterface.downloadExternalLink.bind(i._storageInterface))(e)},testExternalLink:function(e){return d(i._storageInterface.testExternalLink.bind(i._storageInterface))(e)}},i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(t,e),s(t,null,[{key:"connect",value:function(e){var n=e.userId,i=_[n]=_[n]||new t(e._apiRoot,n);return i._connect(e),i}},{key:"disconnect",value:function(e){var t=e.userId;_[t]&&_[t]._disconnect(e)}}]),s(t,[{key:"getCachedPath",value:function(e){var t=this._getCacheEntry(e);return this._isPath(t)?t:void 0}},{key:"getCachedError",value:function(e){var t=this._config.validateURL(e.getContentURL(),this._privateCollection);if(t)return t;var n=this._getCacheEntry(e);return this._isErrorCode(n)?new l(n,"Broken link, or access denied"):null}},{key:"getExternalLink",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=e.getContentURL(),o=this._config.validateURL(i,this._privateCollection);if(o)return Promise.reject(o);if(n)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry(["urls",i]);else{var r=this._getCacheEntry(e);if(this._isPath(r))return Promise.resolve(r);if(this._isErrorCode(r))return Promise.reject(new l(r,"Broken link, or access denied"))}if(this._config.SHARED_LOCAL_STORAGE)return this._sharedStorage.downloadExternalLink(e);if(!this._pendingDownloads[i]){var a=function(){t._notifyDownloadFinished(t._pendingDownloads[i]);var n=e.element;n.supportsVectorThumbnail()&&n.library._renditionCache._clearCache(n,"vector"),delete t._pendingDownloads[i]};this._pendingDownloads[i]={promise:this._doGetExternalLink(e),representations:[]},this._pendingDownloads[i].promise.then(a,a)}return this._pendingDownloads[i].representations.push(e),this._pendingDownloads[i].promise}},{key:"testExternalLink",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=e.getContentURL();if(this._config.validateURL(i,this._privateCollection))return Promise.reject();if(n)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry(["urls",i]);else{var o=this._getCacheEntry(e);if(o)return this._isErrorCode(o)?Promise.reject():Promise.resolve()}if(this._config.SHARED_LOCAL_STORAGE&&this._privateCollection._storageInterface.supportsTestExternalLink())return this._sharedStorage.testExternalLink(e);if(!this._pendingTests[i]){var r=this._getOnDownloadProgressCallback("_pendingTests",i),a=function(){t._notifyDownloadFinished(t._pendingTests[i]),r(),delete t._pendingTests[i]};this._pendingTests[i]={promise:this._doTest(i),representations:[]},r(0,1),this._pendingTests[i].promise.then(a,a)}return this._pendingTests[i].representations.push(e),this._pendingTests[i].promise}},{key:"ensureExternalLinkCache",value:function(e,t){var n=this,i=this._getCache(["urls",e]);return this._getFilePath(i)?Promise.resolve():this._doTransaction((function(){return n._setCache(["urls",e],t)}))}},{key:"gc",value:function(){var e=this,t={};this._collections.forEach((function(n){n.libraries.forEach((function(n){Object.assign(t,e._getReferences(n))}))}));var n=this._cache.urls||{},i=!1;return Object.keys(n).forEach((function(n){t[n]||(e._setCacheEntry(["urls",n]),i=!0)})),i?this.save():Promise.resolve()}},{key:"_connect",value:function(e){this._collections.push(e),e._externalLinkCache=this}},{key:"_disconnect",value:function(e){var t=this._collections.indexOf(e);-1!==t&&this._collections.splice(t,1),0===this._collections.length&&delete _[this._userId]}},{key:"_getCacheEntry",value:function(e){var t=e.element.library._renditionCache._legacyGetCacheEntry(e);if(t)return t;var n=e.getContentURL(),i=this._getCache(["urls",n]);return this._getFilePath(i,!0)}},{key:"_doGetExternalLink",value:function(e){var t=this,n=e.getContentURL(),i=e._getLinkLocalPaths().find((function(e){return t._fs.statSync(e)}));return i?this._doTransaction((function(){return t._setCache(["urls",n],i)})):this._doDownload(n,e.type)}},{key:"_doDownload",value:function(e,t){var n=this,i=this._getOnDownloadProgressCallback("_pendingDownloads",e),o=this._privateCollection._getTempDir();return this._downloadURL(this._privateCollection,e,o,i).then((function(o){var r=o.tempFilePath,a=o.response,s=n._config.getContentTypeHeader(a&&a.headers)||t,c=r+"."+(u.getExtensions(s)[0]||"data"),l=n._fs.rename(r,c).then((function(){return n._doTransaction((function(){return n._setCache(["urls",e],c,!0)}))}));return l.then(i,i),l})).catch((function(t){var o,r=t&&t.response&&t.response.statusCode;return n._config.isUnrecoverableClientError(r)?(n._setCacheEntry(["urls",e],l.RENDITION_NOT_AVAILABLE),o=n.save().then((function(){return Promise.reject(new l(l.RENDITION_NOT_AVAILABLE,"Broken link, or access denied"))}))):o=Promise.reject(h.getSyncError(t)),o.catch((function(){return i(void 0,void 0,t)})),o}))}},{key:"_doTest",value:function(e){var t=this;return this._testURL(this._privateCollection,e).then((function(n){var i,o=n&&n.statusCode;return t._config.isUnrecoverableClientError(o)?i=l.RENDITION_NOT_AVAILABLE:o&&o>=200&&o<400&&(i=t._config.RENDITION_CACHE_PLACEHOLDER),i?(t._setCacheEntry(["urls",e],i),t.save().then((function(){return t._isErrorCode(i)?Promise.reject():Promise.resolve()}))):Promise.resolve()}))}},{key:"_getOnDownloadProgressCallback",value:function(e,t){var n=this;return function(i,o,r){var a=n[e]&&n[e][t]&&n[e][t].representations;a&&a.forEach((function(e){e.element.library.collection._updateExternalLinkDownloadProgress(e,i,o,r)}))}}},{key:"_notifyDownloadFinished",value:function(e){var t=this;e.representations.forEach((function(e){return t._notifyDownloadRendition(e,!0)}))}},{key:"_notifyDownloadRendition",value:function(e,t){var n="".concat(e.element.library.id,".").concat(e.element.id,".").concat(e.id);!0!==t&&this._sentNotifications[n]||(this._sentNotifications[n]=!0,!1!==t&&this._storageInterface.notifyDownloadRendition(e.element))}},{key:"_getReferences",value:function(e){var t=this;if(this._referencedLinks[e.id]=this._referencedLinks[e.id]||{},this._referencedLinks[e.id].modified!==e.modified){this._referencedLinks[e.id].modified=e.modified,this._referencedLinks[e.id].urlMap={};var n=function(n){n._shouldGCLocalData()||n._forEachRepresentation((function(n){var i=n.isExternalLink&&n.getContentURL();i&&(t._referencedLinks[e.id].urlMap[i]=!0)}))};e.elements.forEach(n),e.removedElements.forEach(n)}return this._referencedLinks[e.id].urlMap}},{key:"_downloadURL",value:function(e,t,n,i){var o=this;return new Promise((function(r,a){var s=Date.now();o._services.log("Downloading from external URL: "+t),e._syncManager.links.download(t,{},n,i,(function(e,t,n,i){o._services.log("Finished downloading from external URL: "+(Date.now()-s)+"ms"),e?a(e):r({tempFilePath:t,etag:n,response:i})}))}))}},{key:"_testURL",value:function(e,t){var n=this;return new Promise((function(i){var o=Date.now();n._services.log("HEAD request of external URL: "+t),n._storageInterface.testURL(e,t,(function(e,t){n._services.log("Finished HEAD request of external URL: "+(Date.now()-o)+"ms"),i(t)}))}))}},{key:"_privateCollection",get:function(){return this._collections.find((function(e){return e.isPrivate}))}}]),t}(p);e.exports=f},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],i=!0,o=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){o=!0,r=e}finally{try{i||null==s.return||s.return()}finally{if(o)throw r}}return n}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,o)}function l(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var r=e.apply(t,n);function a(e){c(r,i,o,a,s,"next",e)}function s(e){c(r,i,o,a,s,"throw",e)}a(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function p(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e,t,n){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var m=n(30),v=n(2),y=n(8),g=n(1),E=n(0),O=function(e){function t(){return u(this,t),p(this,_(t).apply(this,arguments))}var n,i,r,s,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}(t,e),n=t,(i=[{key:"_dosync",value:function(e,t){var n=this;this._clearSyncErrors();var i={},o=this._libraries.map(function(){var e=l(regeneratorRuntime.mark((function e(t){var o,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=function(e){return new Promise((function(i){t._sync(!e,(function(e,t){e&&n._reportSyncError(e),i(t)}))}))},e.prev=1,!t._dcxComposite.getLocalData("migrateFromStorageUrl")){e.next=10;break}return e.next=5,n._doMigrationFromStorageUrl(t);case 5:if(t=e.sent){e.next=8;break}return e.abrupt("return");case 8:e.next=12;break;case 10:if(t.isPushedToServer){e.next=12;break}return e.abrupt("return",o(!1));case 12:return e.next=14,n._updateLibraryMetadata(t,i);case 14:return e.next=16,new Promise((function(e){return n._syncManager.hasCompositeChangedOnServer(t._dcxComposite,e)}));case 16:return r=e.sent,e.abrupt("return",o(r));case 20:e.prev=20,e.t0=e.catch(1),n._reportSyncError(e.t0);case 23:case"end":return e.stop()}}),e,null,[[1,20]])})));return function(t){return e.apply(this,arguments)}}());o.push(this._handlePendingDeletes().then((function(){return!1}))),Promise.all(o).then((function(e){n._handleExternalPendingDeletes(),t(null,e.some((function(e){return e})))}))}},{key:"_updateLibraryMetadata",value:(c=l(regeneratorRuntime.mark((function e(t){var n,i,o,r,s,c,l,u,h,p,d,_,f,m,v,y=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=y.length>1&&void 0!==y[1]?y[1]:{},o=!1,e.prev=2,e.next=5,this._getPlatformData(t,n);case 5:i=e.sent,e.next=14;break;case 8:if(e.prev=8,e.t0=e.catch(2),!(r=e.t0.response||e.t0.underlyingError&&e.t0.underlyingError.response)||![403,404].includes(r.statusCode)){e.next=13;break}return e.abrupt("return");case 13:throw e.t0;case 14:c=(s=i).links,l=s.isWritable,u=s.parentAssetId,h=s.isParentWritable,p=s.storageAssignee,d=s.repoName,_=s.repoMetadata,f=d.replace(/\.cclibc$/,""),t._dcxComposite.isPendingRename||"org"!==t.ownerType||t._dcxComposite.name===f||(t._dcxComposite.name=f,o=!0),m=a({},this._getCompositeLinks(t._dcxComposite),{_expiry:void 0}),v=a({},c,{_expiry:void 0}),JSON.stringify(m)!==JSON.stringify(v)&&(this._setCompositeLinks(t._dcxComposite,c),o=!0),JSON.stringify(t._dcxComposite.repoMetadata)!==JSON.stringify(_)&&(t._dcxComposite.repoMetadata=_,o=!0),t._dcxComposite.isWritable!==l&&(t._dcxComposite.isWritable=l,o=!0),JSON.stringify(t._dcxComposite.storageAssignee)!==JSON.stringify(p)&&(t._dcxComposite.storageAssignee=p,o=!0),u&&(t._dcxComposite.parentAssetId!==u&&(t._dcxComposite.parentAssetId=u,o=!0),t._dcxComposite.isParentWritable!==h&&(t._dcxComposite.isParentWritable=h,o=!0)),o&&(t._commit(!0,!0),t._notifyChange());case 25:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(e){return c.apply(this,arguments)})},{key:"_doMigrationFromStorageUrl",value:(s=l(regeneratorRuntime.mark((function e(t){var n,i,o,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._services.log("Migrating library ".concat(t.id," from storage URL")),n=t._dcxComposite.getLocalData("migrateFromStorageUrl"),e.prev=2,e.next=5,this._syncManager._doJSONRequest("HEAD",n);case 5:if(i=e.sent,o=i&&i.headers["x-resource-urn"],404!==i.statusCode){e.next=13;break}return e.next=10,new Promise((function(e,n){return r._unloadLibrary(t,(function(t){return t?n(t):e()}))}));case 10:return e.abrupt("return");case 13:if(200===i.statusCode){e.next=15;break}throw new g(g.NETWORK_ERROR,"Unexpected response from storage service. Code: ".concat(i.statusCode));case 15:if(o){e.next=17;break}throw new g(g.TRANSFER_ERROR,"X-Resource-Urn not provided for asset. Can't migrate.");case 17:return t._dcxComposite.setLocalData("migrateFromStorageUrl"),t._dcxComposite.assetId=o,this._services.log("Finished migrating library ".concat(t.id," from storage URL - Success. Asset id is ").concat(o)),e.abrupt("return",t);case 23:throw e.prev=23,e.t0=e.catch(2),this._services.log("Unable to migrate library ".concat(t.id,". Error: ").concat(e.t0)),e.t0;case 27:case"end":return e.stop()}}),e,this,[[2,23]])}))),function(e){return s.apply(this,arguments)})},{key:"createLibrary",value:function(e,n){if(!n)throw new g(g.INVALID_PARAMETER,"A platform folder must be provided.");if(!n.isWritable)throw new g(g.NOT_ALLOWED,"Cannot create a library in a read-only folder.");return d(_(t.prototype),"createLibrary",this).call(this,e,n)}},{key:"_getNewCompositeHref",value:function(e,t){return v.getTemplateFromLinks(t.links,y.CREATE)}},{key:"_prepareCompositeForPush",value:function(e,n){return e.parentAssetId=n.id,e.storageAssignee={id:n.owner,type:n.ownerType},e.isParentWritable=!0,e.isWritable=!0,d(_(t.prototype),"_prepareCompositeForPush",this).call(this,e,n)}},{key:"removeLibrary",value:function(e,n){if(!e.isWritable)return n(new g(g.NOT_ALLOWED,"Library cannot be deleted. Collection is not writable. ".concat(e.id)));d(_(t.prototype),"removeLibrary",this).call(this,e,n)}},{key:"_syncNewLibrary",value:function(e,t,n,i){var o=this;if(!t)return i(new g(g.INVALID_PARAMETER));this._getPlatformDataFromAssetId(t).then((function(r){var a=r.links,s=r.isWritable,c=r.parentAssetId,l=r.isParentWritable,u=r.storageAssignee,h=r.repoMetadata;if(!v.getUrlFromLinks(a,y.DISCARD))return i();var p=v.getUrlFromLinks(a,y.PRIMARY),d=o._services.hasFileSystem()&&o._getCompositeDir(e),_=o._services.dcx.newCompositeWithHref(p,d);o._setCompositeLinks(_,a),_.repoMetadata=h,_.isWritable=s,_.storageAssignee=u,_.assetId=t,c&&(_.parentAssetId=c,_.isParentWritable=l),o._syncNewLibraryWithComposite(e,_,n,i)}),(function(e){return i(e.code!==g.NOT_FOUND&&e,void 0)}))}},{key:"unloadLibrary",value:function(e,t){return this._unloadLibrary(e,t)}},{key:"_getLibrariesToUnload",value:function(){var e=this;return this.libraries.filter((function(t){return!e._bookmarkManager.findBookmark(t)||t.isPushedToServer&&!v.getUrlFromLinks(t._dcxComposite.links,y.DISCARD)}))}},{key:"_onLibraryPush",value:function(e,t){var n=this,i=function(){!t&&n.libraries.includes(e)||n._bookmarkManager.sync()};t?this._handleExternalPendingDeletes().then(i):i()}},{key:"_getLinksFromAssetId",value:function(e){var t=this;return new Promise((function(n,i){return t._syncManager._storageService.getLinksFromUrn(e,(function(e,t){return e?i(e):n(t)}))}))}},{key:"_getParentInfo",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=v.getUrlFromLinks(e,y.DIRECTORY);return i?(n[i]=n[i]||new Promise((function(e,n){t._syncManager._storageService.getLinksFromUrl(i,(function(i,o,r){if(i)return i.response&&404===i.response.statusCode?e({permissions:[],assetId:void 0}):n(i);var a=r.headers["x-resource-id"];t._getPermissions(o).then((function(t){return e({permissions:t,assetId:a})}),n)}))})),n[i]):Promise.reject()}},{key:"_getPermissions",value:function(e){var t=this;return new Promise((function(n,i){t._syncManager._storageService.getEffectiveACFromLinks(e,(function(e,t){return e?i(e):n(t)}))}))}},{key:"_getRepoMetadata",value:function(e){var t=this;return new Promise((function(n,i){t._syncManager._storageService.getRepoMetadataFromLinks(e,(function(e,t){return e?i(e):n(t)}))}))}},{key:"_setCompositeLinks",value:function(e,t){t._expiry=Date.now()+this._config.PLATFORM_DATA_TTL,e.links=t,e.href=v.getUrlFromLinks(t,y.PRIMARY)}},{key:"_getCompositeLinks",value:function(e){var t=e.links;if(t&&t._expiry&&t._expiry>Date.now())return t}},{key:"_getPlatformData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this._getPlatformDataFromAssetId(e._dcxComposite.assetId,this._getCompositeLinks(e._dcxComposite),t)}},{key:"_getPlatformDataFromAssetId",value:(r=l(regeneratorRuntime.mark((function e(t,n){var i,r,a,s,c,l,u,h,p,d,_,f=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=f.length>2&&void 0!==f[2]?f[2]:{},n){e.next=15;break}return e.prev=2,e.next=5,this._getLinksFromAssetId(t);case 5:n=e.sent,e.next=15;break;case 8:if(e.prev=8,e.t0=e.catch(2),e.t0.code!==E.UNEXPECTED_RESPONSE||404!==e.t0.response.statusCode){e.next=14;break}throw new g(g.NOT_FOUND,"Requested asset not found: ".concat(t),void 0,e.t0);case 14:throw e.t0;case 15:return e.prev=15,e.next=18,Promise.all([this._getPermissions(n),this._getParentInfo(n,i),this._getRepoMetadata(n)]);case 18:return r=e.sent,a=o(r,3),s=a[0],c=a[1],l=a[2],u=s.includes("write"),h=c&&c.assetId,p=c&&c.permissions.includes("write"),d=l["storage:assignee"],_=l["repo:name"],e.abrupt("return",{links:n,isWritable:u,parentAssetId:h,isParentWritable:p,storageAssignee:d,repoName:_,repoMetadata:l});case 31:throw e.prev=31,e.t1=e.catch(15),this._services.log("Unable to fetch platform data for library: ".concat(e.t1)),e.t1;case 35:case"end":return e.stop()}}),e,this,[[2,8],[15,31]])}))),function(e,t){return r.apply(this,arguments)})},{key:"supportsONSNotifications",get:function(){return!0}}])&&h(n.prototype,i),t}(m);e.exports=O},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(7),r=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._apiRoot=t,this._collections=[],this._listenerManager=new o(["change"],(function(e){return n._services.log(e)}))}var t,n;return t=e,(n=[{key:"getLibraryCollection",value:function(e,t){return this._collections.find((function(n){return n.isPrivate&&n.userId===e&&n.cloudId===t}))}},{key:"getPublicLibraryCollection",value:function(e){return this._collections.find((function(t){return t.isPublic&&t.cloudId===e}))}},{key:"getCollaboratedLibraryCollection",value:function(e){return this._collections.find((function(t){return t.isCollaborated&&t.userId===e}))}},{key:"addLibraryCollection",value:function(e){this._collections.push(e),this._listenerManager.notify("change")}},{key:"removeLibraryCollection",value:function(e){e._dispose();var t=this._collections.indexOf(e);-1!==t&&(this._collections.splice(t,1),this._listenerManager.notify("change"))}},{key:"removeAllLibraryCollections",value:function(){this._collections.forEach((function(e){return e._dispose()})),this._collections=[],this._listenerManager.notify("change")}},{key:"getLoadedCollections",value:function(){return this._collections}},{key:"addLoadedCollectionsListener",value:function(e){this._listenerManager.add("change",e)}},{key:"removeLoadedCollectionsListener",value:function(e){this._listenerManager.remove("change",e)}},{key:"_services",get:function(){return this._apiRoot._services}}])&&i(t.prototype,n),e}();e.exports=r},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r=n(4),a="undefined"!==("undefined"==typeof LOCALE_ROOT?"undefined":o(LOCALE_ROOT)),s={photoshop:"LIBS_TOOLKIT_NAME_PHOTOSHOP",photoshop_swatches:"LIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES",photoshop_brushes:"LIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES",photoshop_gradients:"LIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS",photoshop_patterns:"LIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS",photoshop_styles:"LIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES",photoshop_shapes:"LIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES"},c=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._apiRoot=t,this._localeData={},this._services.hasFileSystem()&&a||(this._localeData={cs_CZ:n(87),da_DK:n(88),de_DE:n(89),en_US:n(90),es_ES:n(91),es_MX:n(92),fi_FI:n(93),fr_CA:n(94),fr_FR:n(95),fr_MA:n(96),hu_HU:n(97),it_IT:n(98),ja_JP:n(99),ko_KR:n(100),nb_NO:n(101),nl_NL:n(102),pl_PL:n(103),pt_BR:n(104),ru_RU:n(105),sv_SE:n(106),tr_TR:n(107),uk_UA:n(108),zh_CN:n(109),zh_TW:n(110)}),this.setLocale(i)}var t,o;return t=e,(o=[{key:"_getLocaleData",value:function(e){if(!this._localeData[e]&&this._services.hasFileSystem()&&a)try{this._localeData[e]=this._services.fs.readFileSync("".concat(LOCALE_ROOT).concat(e,"/messages.properties"),"utf8")}catch(e){}return this._localeData[e]||""}},{key:"_normaliseLocale",value:function(e){var t=(e=e.replace("-","_")).split("_");return t[0]=t[0]&&t[0].toLowerCase(),t[1]=t[1]&&t[1].toUpperCase(),t.join("_")}},{key:"setLocale",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";e=this._normaliseLocale(e),this._getLocaleData(e)||(e="en_US"),this._locale=e,this._strings=r.parseLocalisationFile(this._getLocaleData(e))}},{key:"getLocale",value:function(){return this._locale}},{key:"translate",value:function(e,t){var n=this._strings[e];return n&&t&&(n=r.constructStringFromTemplate(n,t)),n||e}},{key:"getToolkitName",value:function(e){return this.translate(s[e]||"LIBS_TOOLKIT_NAME_DEFAULT")}},{key:"_services",get:function(){return this._apiRoot._services}}])&&i(t.prototype,o),e}();e.exports=c},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Vaše knihovna\nLIBS_RECOVERED_LIBRARY={{name}} (obnoveno)\nLIBS_TOOLKIT_NAME_DEFAULT=Vaše sada nástrojů\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Vaše knihovna aplikace Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Vaše vzorníky v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Vaše štětce v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Vaše přechody v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Vaše vzory v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Vaše styly v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Vaše tvary v aplikaci Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Dit bibliotek\nLIBS_RECOVERED_LIBRARY={{name}} (Gendannet)\nLIBS_TOOLKIT_NAME_DEFAULT=Din værktøjspakke\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Dit Photoshop-bibliotek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Dine Photoshop-farveprøver\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Dine Photoshop-pensler\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Dine Photoshop-farveforløb\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Dine Photoshop-mønstre\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Dine Photoshop-typer\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Dine Photoshop-former"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ihre Bibliothek\nLIBS_RECOVERED_LIBRARY={{name}} (Wiederhergestellt)\nLIBS_TOOLKIT_NAME_DEFAULT=Ihr Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ihre Photoshop-Bibliothek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Ihre Photoshop-Farbfelder\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Ihre Photoshop-Pinsel\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Ihre Photoshop-Verläufe\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Ihre Photoshop-Muster\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Ihre Photoshop-Stile\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Ihre Photoshop-Formen"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Your Library\nLIBS_RECOVERED_LIBRARY={{name}} (Recovered)\nLIBS_TOOLKIT_NAME_DEFAULT=Your Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Your Photoshop Library\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Your Photoshop Swatches\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Your Photoshop Brushes\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Your Photoshop Gradients\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Your Photoshop Patterns\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Your Photoshop Styles\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Your Photoshop Shapes"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Su biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Su kit de herramientas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Su biblioteca de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Sus muestras de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Sus pinceles de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Sus degradados de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Sus motivos de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Sus estilos de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Sus formas de Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Su biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Su kit de herramientas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Su biblioteca de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Sus muestras de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Sus pinceles de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Sus degradados de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Sus motivos de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Sus estilos de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Sus formas de Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Oma kirjasto\nLIBS_RECOVERED_LIBRARY={{name}} (palautettu)\nLIBS_TOOLKIT_NAME_DEFAULT=Oma työkalusarja\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Oma Photoshop-kirjasto\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Omat Photoshop-värimallit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Omat Photoshop-siveltimet\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Omat Photoshop-liukuvärit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Omat Photoshop-kuviot\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Omat Photoshop-tyylit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Omat Photoshop-muodot"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Votre bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Vos nuances Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Vos pinceaux Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Vos dégradés Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Vos motifs Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Vos styles Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Vos formes Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Votre bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Vos nuances Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Vos pinceaux Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Vos dégradés Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Vos motifs Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Vos styles Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Vos formes Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Votre bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Vos nuances Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Vos pinceaux Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Vos dégradés Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Vos motifs Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Vos styles Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Vos formes Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Az Ön könyvtára\nLIBS_RECOVERED_LIBRARY={{name}} (helyreállított)\nLIBS_TOOLKIT_NAME_DEFAULT=Az Ön eszköztára\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Az Ön Photoshop könyvtára\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Az Ön Photoshop színtárai\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Az Ön Photoshop ecsetei\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Az Ön Photoshop színátmenetei\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Az Ön Photoshop mintái\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Az Ön Photoshop stílusai\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Az Ön Photoshop alakzatai"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Libreria\nLIBS_RECOVERED_LIBRARY={{name}} (recuperato)\nLIBS_TOOLKIT_NAME_DEFAULT=Il vostro toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=La vostra Libreria Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Campioni di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Pennelli di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Sfumature di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Pattern di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Stili di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Forme di Photoshop personali"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=ライブラリ\nLIBS_RECOVERED_LIBRARY={{name}} (回復済み)\nLIBS_TOOLKIT_NAME_DEFAULT=自分の Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop ライブラリ\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=あなたの Photoshop スウォッチ\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=あなたの Photoshop ブラシ\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=あなたの Photoshop グラデーション\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=あなたの Photoshop パターン\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=あなたの Photoshop スタイル\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=あなたの Photoshop シェイプ"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=귀하의 라이브러리\nLIBS_RECOVERED_LIBRARY={{name}}(복구됨)\nLIBS_TOOLKIT_NAME_DEFAULT=툴킷\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop Library\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Photoshop 견본\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Photoshop 브러시\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Photoshop 그래디언트\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Photoshop 패턴\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Photoshop 스타일\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Photoshop 모양"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ditt bibliotek\nLIBS_RECOVERED_LIBRARY={{name}} (gjenopprettet)\nLIBS_TOOLKIT_NAME_DEFAULT=Ditt verktøysett\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ditt Photoshop-bibliotek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Dine Photoshop-fargekart\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Dine Photoshop-pensler\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Dine Photoshop-graderinger\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Dine Photoshop-mønstre\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Dine Photoshop-stiler\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Dine Photoshop-former"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Uw bibliotheek\nLIBS_RECOVERED_LIBRARY={{name}} (hersteld)\nLIBS_TOOLKIT_NAME_DEFAULT=Uw toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Uw Photoshop-bibliotheek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Uw Photoshop-stalen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Uw Photoshop-penselen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Uw Photoshop-verlopen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Uw Photoshop-patronen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Uw Photoshop-stijlen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Uw Photoshop-vormen"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Twoja biblioteka\nLIBS_RECOVERED_LIBRARY={{name}} (Odzyskane)\nLIBS_TOOLKIT_NAME_DEFAULT=Twój zestaw narzędzi\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Biblioteka programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Próbki programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Pędzle programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Gradienty programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Wzory programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Style programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Kształty programu Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Sua biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (Recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Seu kit de ferramentas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Sua biblioteca do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Suas amostras do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Seus pincéis do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Seus gradientes do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Seus padrões do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Seus estilos do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Suas formas do Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ваша библиотека\nLIBS_RECOVERED_LIBRARY={{name}} (восстановлено)\nLIBS_TOOLKIT_NAME_DEFAULT=Инструменты\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Библиотека Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Ваши образцы Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Ваши кисти Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Ваши градиенты Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Ваши узоры Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Ваши стили Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Ваши фигуры Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ditt bibliotek\nLIBS_RECOVERED_LIBRARY={{name}} (återskapet)\nLIBS_TOOLKIT_NAME_DEFAULT=Ditt Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ditt Photoshop-bibliotek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Dina Photoshop-färgrutor\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Dina Photoshop-penslar\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Dina Photoshop-övertoningar\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Dina Photoshop-mönster\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Dina Photoshop-format\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Dina Photoshop-former"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Kitaplığınız\nLIBS_RECOVERED_LIBRARY={{ad}} ((Kurtarıldı))\nLIBS_TOOLKIT_NAME_DEFAULT=Araç Setiniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop Kitaplığınız\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Photoshop Renk Örnekleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Photoshop Fırçalarınız\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Photoshop Degradeleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Photoshop Desenleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Photoshop Stilleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Photoshop Şekilleriniz"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ваша бібліотека\nLIBS_RECOVERED_LIBRARY={{name}} (відновлено)\nLIBS_TOOLKIT_NAME_DEFAULT=Мій інструментарій\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Моя бібліотека Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Ваші зразки робіт, створені за допомогою Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Ваші пензлі Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Ваші градієнти Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Ваші візерунки Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Ваші стилі Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Ваші фігури Photoshop"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=您的库\nLIBS_RECOVERED_LIBRARY={{name}} （已恢复）\nLIBS_TOOLKIT_NAME_DEFAULT=您的工具箱\nLIBS_TOOLKIT_NAME_PHOTOSHOP=您的 Photoshop 库\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=您的 Photoshop 色板\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=您的 Photoshop 画笔\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=您的 Photoshop 渐变\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=您的 Photoshop 图案\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=您的 Photoshop 样式\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=您的 Photoshop 形状"},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=您的資料庫\nLIBS_RECOVERED_LIBRARY={{name}} (已復原)\nLIBS_TOOLKIT_NAME_DEFAULT=您的工具組。\nLIBS_TOOLKIT_NAME_PHOTOSHOP=您的 Photoshop 資料庫\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=您的 Photoshop 色票\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=您的 Photoshop 筆刷\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=您的 Photoshop 漸層\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=您的 Photoshop 圖樣圖樣\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=您的 Photoshop 樣式\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=您的 Photoshop 形狀"},function(e,t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=n(12),s=n(13),c=n(29),l=n(41),u=n(42),h=n(17),p=n(1),d=n(112),_=n(113),f=n(114),m=n(6),v=n(4).promisify,y=function(e){return{isCollaborated:e.isCollaborated,isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId}},g=function(e){return{id:e.id}},E=function(e,t){return Object.assign(y(e.collection),r({},t||"id",e.id))},O=function(e,t,n){return Object.assign(E(e.library,n),r({},t||"element",e.id))},A=function(e){return Object.assign(O(e.element),{representation:e.id})},S=["bmp","cur","gif","ico","jpeg","jpg","png","psd","tiff","tif","webp","svg","dds"],b=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,e),this._apiRoot=t,this._acceptPushedBranchListeners=[],this._downloadRenditionListeners=[],this._rootListeners=[],this._baseBranches={},this._portDiagnosis="UNKNOWN",this._logIndex=0,this._connectedCallback=n.onConnected||function(){},this._config.SHARED_LOCAL_STORAGE&&(this._connect(),this.fs=new f(this),this._services.hasFileSystem()||this._services.setFileSystem(this.fs))}var t,n;return t=e,(n=[{key:"_getBase",value:function(e){var t=this._baseBranches[e];return t&&t.base}},{key:"_setBase",value:function(e,t){this._baseBranches[e]=this._baseBranches[e]||{},this._baseBranches[e].base=t}},{key:"_getLogIndex",value:function(){return this._logIndex++}},{key:"_getServicePort",value:function(e){var t=this._config.VULCAN_PREFIX+this._config.VULCAN_QUERY_REQUEST,n=this._config.VULCAN_PREFIX+this._config.VULCAN_QUERY_RESPONSE,i=function(t){var n;try{n=JSON.parse(t)}catch(e){}n?e(null,n):e("NO_DATA")};if(this._services.vulcanCall)this._services.vulcanCall(t,"",n,i);else if(this._services.hasCEPVulcan()){var o,r=this._services.getVulcanInterface(),a=this._services.getVulcanMessage(),s=function t(a){r.removeMessageListener(n,t),clearTimeout(o),a?i(r.getPayload(a)):e("NO_VULCAN_MESSAGE")};r.addMessageListener(n,s),o=setTimeout(s,this._config.VULCAN_QUERY_TIMEOUT);var c=new a(t);c.setPayload(""),r.dispatchMessage(c)}}},{key:"_connectToPort",value:function(e,t){var n=this,i=t&&t.port,o=t&&t.token,r=t&&t.domain;if(this._portDiagnosis=t?t.portdiagnosis:"UNKNOWN",this._connectionPort=i,!this._channel){if(!i||"SIMPLE_HOSTNAME_GOING_TO_PROXY"===this._portDiagnosis)return this._onConnect(e);try{var a=function(e){return n._services.log(e)},s=new _(i,o,r,this._config.SHARED_LOCAL_STORAGE_VERSION,a);this._channel=new d(this._apiRoot,s),this._channel.setLogCallback(a)}catch(e){return this._onConnect(e)}this._channel.addListener("environmentinfo",this._onEnvironmentInfo.bind(this)),this._channel.addListener("collectionadded",this._onCollectionAdded.bind(this)),this._channel.addListener("collectionremoved",this._onCollectionRemoved.bind(this)),this._channel.addListener("clearcollections",this._onClearCollections.bind(this)),this._channel.addListener("syncstate",this._onSyncState.bind(this)),this._channel.addListener("librarychange",this._onLibraryChange.bind(this)),this._channel.addListener("renditioncachechange",this._onRenditionCacheChange.bind(this)),this._channel.addListener("librarydeleted",this._onLibraryDeleted.bind(this)),this._channel.addListener("bookmarkschanged",this._onBookmarksChanged.bind(this)),this._channel.addListener("folderschanged",this._onFoldersChanged.bind(this)),this._channel.addListener("fontcachechanged",this._onFontCacheChanged.bind(this)),this._channel.addListener("operationschanged",this._onOperationsChanged.bind(this)),this._channel.onOpen((function(){n._services.log("Websocket opened"),n._isConnected=!0,n._sendConfiguration(),n._onConnect()})),this._channel.onClose((function(){n._services.log("Websocket closed"),n._onDisconnect()})),this._channel.onError((function(e){n._services.log("Websocket error: ".concat(e)),n._onDisconnect()}))}}},{key:"_connect",value:function(){this._getServicePort(this._connectToPort.bind(this))}},{key:"_onConnect",value:function(e){!this._channel||e?this._connectedCallback(new p(p.CLIENT_CONNECTION_ERROR,"Error creating message channel",e)):this._connectedCallback()}},{key:"_onDisconnect",value:function(){this._channel&&(this._channel.shutdown(),this._channel=void 0),this._isConnected=!1,this._collectionManager.removeAllLibraryCollections()}},{key:"_sendConfiguration",value:function(){this._channel.send("configure",{CLIENT_DESCRIPTION:this._config.CLIENT_DESCRIPTION,RENDITION_SIZES:this._config.RENDITION_SIZES,FULL_RENDITION_CONFIG:this._config.FULL_RENDITION_CONFIG,LOCAL_SETTINGS:this._config.LOCAL_SETTINGS})}},{key:"_onEnvironmentInfo",value:function(e){var t=!this._serviceInfo||!this._serviceInfo.syncingEnabled;this._serviceInfo=e,e.allowedDomains&&(this._config.ALLOWED_DOMAINS=e.allowedDomains),e.elementActionProductMap&&this._config.updateElementActionMap(this._getServiceVersion(),e.elementActionProductMap),e.documentLibraryActionProductMap&&(this._config.DOCUMENT_LIBRARY_ACTION_PRODUCT_MAP=e.documentLibraryActionProductMap),e.deviceId&&(this._config.DEVICE_ID=e.deviceId),e.deviceDescription&&(this._config.DEVICE_DESCRIPTION=e.deviceDescription),e.maxElements&&(this._config.MAX_ELEMENTS=e.maxElements),e.maxRemovedElements&&(this._config.MAX_REMOVED_ELEMENTS=e.maxRemovedElements),e.maxComponentSize&&(this._config.MAX_COMPONENT_SIZE=e.maxComponentSize),e.localSettings&&(this._config.LOCAL_SETTINGS=e.localSettings),e.shaCache&&(this._config.SHA_CACHE=e.shaCache),e.defaultContentLocations&&(this._config.DEFAULT_CONTENT_LOCATIONS=e.defaultContentLocations),e.analyticsEnabled&&(this._config.ANALYTICS_ENABLED=e.analyticsEnabled),this._collectionManager._collections.forEach((function(n){e.syncingEnabled&&t&&(n._syncState="ok"),n._listenerManager.notify("sync")})),this._config._listenerManager.notify("change")}},{key:"_onCollectionAdded",value:function(e){var t=this;this._config.ROOT_DIR=e.rootDir;var n,i={USER_ID:e.userId,CLOUD_ID:e.cloudId,STORAGE_HOSTNAME:e.storageHost,CC_LIBRARY_SERVICE_HOSTNAME:e.cclibsHost,CC_IMAGE_HOSTNAME:e.imageHost,CC_IMAGE_X_HOSTNAME:e.imageXHost,TYPEKIT_HOSTNAME:e.typekitHost,REQUIRES_COMMUNITY_SESSION:e.requiresCommunitySession},o=this._collectionManager.getLoadedCollections().find((function(t){return t.isPrivate&&t.userId===e.userId}));n=e.isPublic?new u(this._apiRoot,i,o):e.isCollaborated?new l(this._apiRoot,i,o):new c(this._apiRoot,i);var r=v(this.loadExistingLibrary.bind(this));Promise.all(e.libraries.map((function(e){return r(n,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache)}))).then((function(){return t._collectionManager.addLibraryCollection(n)}))}},{key:"_getLibraryCollection",value:function(e){return e.isPublic?this._collectionManager.getPublicLibraryCollection(e.cloudId):e.isCollaborated?this._collectionManager.getCollaboratedLibraryCollection(e.userId):this._collectionManager.getLibraryCollection(e.userId,e.cloudId)}},{key:"_onCollectionRemoved",value:function(e){var t=this._getLibraryCollection(e);t&&this._collectionManager.removeLibraryCollection(t)}},{key:"_onClearCollections",value:function(){this._collectionManager.removeAllLibraryCollections()}},{key:"_onSyncState",value:function(e){var t=this._getLibraryCollection(e);t&&(t._userQuota=e.quota,t._syncState=e.state,t._syncProgress=e.progress,t._syncProgressMap=e.progressMap,t._externalLinkDownloadProgressMap=e.externalLinkDownloadProgressMap||{},t._newLibraryProgress=e.newLibraryProgress,t._initialSyncInProgress=e.initialSyncInProgress,t._syncErrors=[],e.errors.forEach((function(e){t._syncErrors.push(new p(e.code,e.message,e.libraryId))})),e.libraryStates.forEach((function(e){var n=t.getLibraryById(e.id);n&&(n._syncState=e.state)})),t._listenerManager.notify("sync"))}},{key:"_onLibraryChange",value:function(e){var t=this._getLibraryCollection(e);if(t){var n=t.getLibraryById(e.id);n?(this._services.log("onLibraryChange: "+n.id),n._deletedFromServer!==e.deletedFromServer&&(n._deletedFromServer=e.deletedFromServer,n._notifyChange()),e.renditionCache=e.renditionCache||{},n._renditionCache.replaceCache(e.renditionCache),this.updateExistingLibrary(t,n,e.manifest,void 0,this._getBase(n.id),(function(){n._renditionCache.replaceCache(e.renditionCache)}))):this.loadExistingLibrary(t,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache)}}},{key:"_onRenditionCacheChange",value:function(e){var t=this._getLibraryCollection(e),n=t&&t.getLibraryById(e.id),i=n&&n.getElementById(e.elementId);i&&e.renditionCache&&(n._renditionCache.replaceElementCache(i,e.renditionCache),i._listenerManager.notify("change"))}},{key:"_onOperationsChanged",value:function(e){var t=this._getLibraryCollection(e),n=e.operations,i={};n.forEach((function(e){t._updateOperation(e.id,e.type,e.data,e.progress),i[e.id]=!0})),Object.keys(t._operationIdMap).forEach((function(e){i[e]||t._delayedRemoveOperation(t._operationIdMap[e])}))}},{key:"_onLibraryDeleted",value:function(e){var t=this._getLibraryCollection(e),n=t&&t.getLibraryById(e.id);if(n){this._services.log("deleteLibrary");var i=t._libraries.indexOf(n);-1!==i&&(t._libraries.splice(i,1),delete t._libraryIdMap[n.id]),n._markDeletedLocally(!0),t._notifyChange(!0)}}},{key:"_onBookmarksChanged",value:function(e){var t=this._getLibraryCollection(e);t&&e.bookmarks&&t._bookmarkManager._deserialize(e.bookmarks)}},{key:"_onFoldersChanged",value:function(e){var t=this._collectionManager.getLoadedCollections().find((function(e){return e.isPrivate}));t&&e&&t._platformManager._fromJSON(e)}},{key:"_onFontCacheChanged",value:function(e){var t=this._getLibraryCollection(e);t&&t.fontManager&&t.fontManager._clearCache()}},{key:"_loadBranch",value:function(e,t,n){try{var i=new s(void 0,n).parse(t);return i._localStorage=e._localStorage,i}catch(e){}}},{key:"_addLibrary",value:function(e,t,n,i,o){n=n||e._getCompositeDir(t);var r=new a(null,null,n,null,null,{preserveFileExtensions:!0}),s=this._loadBranch(r,i,!1);if(s)if("pendingDelete"!==s.compositeState&&"pendingDiscard"!==s.compositeState){r._current=s,this._setBase(t,i);var c=new h(e,r,e.isPublic&&t);e._libraries.push(c),e._libraryIdMap[c.id]=c,e._notifyChange(!0),o(null,c)}else o(null);else o(new p(p.CORRUPTED_LIBRARY,"Library corrupted in local storage",t))}},{key:"isConnected",value:function(){return this._isConnected}},{key:"reconnect",value:function(){this._channel||this._connect()}},{key:"shutdown",value:function(){this._onDisconnect()}},{key:"getServiceInfo",value:function(){return this._serviceInfo?{updateRequired:this._serviceInfo.updateRequired,version:this._serviceInfo.codeVersion,buildNumber:this._serviceInfo.buildNumber,apiVersion:this._serviceInfo.version,environment:this._serviceInfo.environment,syncingEnabled:this._serviceInfo.syncingEnabled,portDiagnosis:this._portDiagnosis,connectionPort:this._connectionPort}:{portDiagnosis:this._portDiagnosis,connectionPort:this._connectionPort}}},{key:"updateConfiguration",value:function(){this._config.SHARED_LOCAL_STORAGE&&this._channel&&this._isConnected&&this._sendConfiguration()}},{key:"sync",value:function(e){this._channel.send("sync",y(e))}},{key:"setSyncEnabled",value:function(e){this._channel.send("configuresync",{enable:e})}},{key:"commitManifest",value:function(e,t){var n=this;if(this._config.SHARED_LOCAL_STORAGE){var i=e._dcxBranch.localData,o=e._renditionCache.doRequestSetCache(),r=E(e);r.current=i,r.base=this._getBase(e.id),r.renditions=o.data,this._services.log("Start commit"),this._channel.call("commit",r,(function(a){n._services.log("Finish commit: "+(a.success?"success":"fail")),a.success?(n._services.log("Update base after commit"),n._setBase(e.id,i),a.renditions&&o.complete(a.renditions).forEach((function(e){return e._listenerManager.notify("change")}))):(o.cancel(),e._waitForCommit((function(){n.notifyStartWrite(e,[],(function(){e._deletedFromServer=a.deletedFromServer,n.updateExistingLibrary(e.collection,e,a.manifest,void 0,r.base,(function(){e._commit(!0,!0)}))}))}))),t(null,a.success)}))}else e._dcxLock.obtain((function(){e._gcLocalData((function(){e._dcxComposite.commitChanges((function(n){e._dcxLock.release(),e._renditionCache.gc(),t(n,!0)}))}))}))}},{key:"resolvePullWithBranch",value:function(e,t,n,i,o){var r=this;this._services.log("resolvePullWithBranch"),this._config.SHARED_LOCAL_STORAGE?(e._dcxComposite._current=t,this._setBase(e.id,n),this._services.log("Finished resolvePullWithBranch: shared local storage"),o(),e._unblockCommits()):i?e._dcxLock.obtain((function(){e._dcxComposite._current=t,e._dcxLock.release(),r._services.log("Finished resolvePullWithBranch: local merge"),o()})):e._dcxLock.obtain((function(){e._dcxComposite.resolvePullWithBranch(t,(function(t,n){e._dcxLock.release(),e._commit(!0,!0),e._waitForCommit((function(){r._services.log("Finished resolvePullWithBranch: remote merge"),o(t,n)}))}))}))}},{key:"acceptPush",value:function(e,t){var n=this;this._services.log("acceptPush"),e._dcxLock.obtain((function(){e._dcxComposite.acceptPush((function(i){e._dcxLock.release(),n._services.log("Finished acceptPush"),n._acceptPushedBranchListeners.forEach((function(t){return t(e)})),t(i)}))}))}},{key:"onAcceptPushedBranch",value:function(e){this._acceptPushedBranchListeners.push(e)}},{key:"removeOnAcceptPushedBranchListeners",value:function(){this._acceptPushedBranchListeners=[]}},{key:"createNewLibrary",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};this._services.log("createNewLibrary"),this._addLibrary(e,t,void 0,n,(function(e,t){!e&&t?(t._commit(!1,!0),t._waitForCommit(i)):i(e)}))}},{key:"loadExistingLibrary",value:function(e,t,n,i,o,r){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};this._services.log("loadExistingLibrary"),this._addLibrary(e,t,void 0,i,(function(e,t){!e&&t?(t._deletedFromServer=o,r&&t._renditionCache.replaceCache(r),a(null,t)):a(e)}))}},{key:"updateExistingLibrary",value:function(e,t,n,i,o){var r=this,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:function(){},s="updateExistingLibrary["+this._getLogIndex()+"]: ",c=function(e){var i=m.getManifestForComparison(t,n);return m.areManifestsEqual(i,e)};if(c(n))return this._services.log(s+"already up-to-date"),void a();var l=this._loadBranch(t._dcxComposite,n,!1);if(this._services.log(s+"changes to update (state = "+(l&&l.compositeState)+")"),l){var u=m.ensureBranchDataValid(l);if(this._services.log(s+"fixed branch data: "+u),"pendingDelete"===l.compositeState||"pendingDiscard"===l.compositeState)return e._doRemoveLibrary(t),void a();t._waitForCommit((function(){if(i){if(!c(i))return r._services.log(s+"Commit aborting: something changed and it's no longer a fast-forward"),void a(!0)}else i=r._getBase(t.id);if(o&&i!==o)return r._services.log(s+"Commit aborting: base manifest changed before we got chance to update!"),void a(!0);var e=r._loadBranch(t._dcxComposite,i,!0)||l;r._services.log(s+"base "+e.changeCount+" -> updated "+l.changeCount),t._mergeAndSwitchToBranch(l,e,(function(){r._services.log(s+"finished merge"),r._config.SHARED_LOCAL_STORAGE?a(null):(t._commit(!1,!0),t._waitForCommit(a))}))}))}else a(new p(p.CORRUPTED_LIBRARY,"Invalid manifest",t.id))}},{key:"getRenditionPath",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=e.library._renditionCache.getCache(e,t||"full");if(r)i(null,r);else{var a=O(e);a.size=t,this._services.log("Get rendition path from CCLibrary process"),this._channel.call("getrenditionpath",a,(function(r){if(!r&&o<n._config.LOCAL_RENDITION_MAX_RETRIES)return n._services.log("getrenditionpath: rendition not found"),void setTimeout((function(){return n.getRenditionPath(e,t,i,o+1)}),n._config.LOCAL_RENDITION_RETRY_INTERVAL);i(null,r)}))}}},{key:"notifyDownloadRendition",value:function(e){this._downloadRenditionListeners.forEach((function(t){return t(e)})),e._listenerManager.notify("change")}},{key:"onDownloadRendition",value:function(e){this._downloadRenditionListeners.push(e)}},{key:"removeOnDownloadRenditionListeners",value:function(){this._downloadRenditionCacheListeners=[]}},{key:"notifyStartWrite",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(this._config.SHARED_LOCAL_STORAGE){var i=E(e);i.dependencies=t.map((function(e){return E(e)})),this._channel.call("startcomponentwrite",i,(function(){return n(null)}))}else n(null)}},{key:"refreshPlatformFolders",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this._channel.call("refreshplatformfolders",{},(function(){return e(null)}))}},{key:"downloadURL",value:function(e,t,n,i,o){if(this._config.SHARED_LOCAL_STORAGE){var r=y(e);r.url=t,r.headers=n,r.tempDir=i,this._channel.call("downloadfile",r,(function(e){o(e.err,e.tempFilePath,e.etag,{headers:e.responseHeaders})}))}else e._syncManager.links.download(t,n,i,void 0,o)}},{key:"testURL",value:function(e,t,n){this._config.SHARED_LOCAL_STORAGE?n(null):e._syncManager.links.test(t,n)}},{key:"downloadExternalLink",value:function(e,t){this._services.log("Download external link from CCLibrary process"),this._channel.call("downloadexternallink",A(e),(function(e){return t(e.err,e.path)}))}},{key:"testExternalLink",value:function(e,t){this._services.log("Test external link via CCLibrary process"),this._channel.call("testexternallink",A(e),(function(e){return t(e.err,e.success)}))}},{key:"clearCachedExternalLink",value:function(e){this._services.log("Clear cached external link via CCLibrary process"),this._channel.send("clearcachedexternallink",A(e))}},{key:"createBookmark",value:function(e,t,n,i,o){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:function(){},a=y(e);a.type=t,a.id=n,a.data=i,a.condition=o,this._channel.call("createBookmark",a,(function(e){var t=e&&e.err,n=e&&e.bookmarks;r(t,n)}))}},{key:"removeBookmark",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=y(e);o.id=t.id,o.removeCollaboration=n,this._channel.call("removeBookmark",o,(function(e){return i(e)}))}},{key:"sendAction",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n={element:function(){return O(e.element,"elementId","libraryId")},library:function(){return E(e.library,"libraryId")}}[e.type],i=n?n():{};i.appCode=e.appCode,i.minVersion=e.minAppVersion,i.action=e.id,this._channel.call("performAction",i,(function(e){return t(e.err,e.data)}))}},{key:"getImageDimensions",value:function(e,t){var n=this._services.fileUtils.getFileExtension(e);!n||S.includes(n)?this._config.SHARED_LOCAL_STORAGE?this._channel.call("getImageDimensions",e,(function(e){return t(e.data)})):this._services.imageSize(e,(function(e,n){return t(n)})):t()}},{key:"importLibrary",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=y(e);o.path=t,o.operationId=n,this._channel.call("importlibrary",o,(function(t){i(t.err,e.getLibraryById(t.libraryId))}))}},{key:"exportLibrary",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=E(e);o.path=t,o.operationId=n,this._channel.call("exportlibrary",o,(function(e){return i(e.err)}))}},{key:"cancelOperation",value:function(e,t){var n=y(e);n.operationId=t,this._channel.send("canceloperation",n)}},{key:"moveLibrary",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=this._collectionManager.getLoadedCollections().find((function(e){return e.isCollaborated}));if(!i)return n(new p(p.INVALID_DATA,"No collaborated collection found."));var o=E(e);o.target=g(t),this._channel.call("movelibrary",o,(function(e){n(e.err,e.libraryId&&i.getLibraryById(e.libraryId))}))}},{key:"getFontData",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=y(e);i.fontId=t,this._channel.call("getfontdata",i,(function(e){return n(e.err,e.data)}))}},{key:"isFontAvailable",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i={fontName:e,matchFamily:t};this._channel.call("isfontavailable",i,(function(e){var t=e.err,i=e.data;return n(t,i)}))}},{key:"getAccessToken",value:function(e,t,n,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){},r={userId:e,clientId:t,clientSecret:n,scopes:i};this._channel.call("getaccesstoken",r,(function(e){var t=e.err,n=e.data;return o(t,n)}))}},{key:"openInCCD",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n={path:e};this._channel.call("openinccd",n,(function(e){var n=e.err,i=e.data;return t(n,i)}))}},{key:"computeSHA",value:function(e){var t=this;return this._config.SHARED_LOCAL_STORAGE?new Promise((function(n,i){t._channel.call("computesha",{path:e},(function(e){var t=e.err,o=e.data;return t?i(t):n(o)}))})):this._services.fileUtils.computeSHA(e)}},{key:"_getServiceVersion",value:function(){var e=this.getServiceInfo();return e&&e.apiVersion||0}},{key:"supportsClearRenditionCache",value:function(){return this._getServiceVersion()>=7}},{key:"supportsTestExternalLink",value:function(){return this._getServiceVersion()>=10}},{key:"_collectionManager",get:function(){return this._apiRoot._collectionManager}},{key:"_services",get:function(){return this._apiRoot._services}},{key:"_config",get:function(){return this._apiRoot._config}}])&&o(t.prototype,n),e}();e.exports=b},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(7),r=function(e){return"".concat(e,"_req")},a=function(e){return"".concat(e,"_res")},s=function(e,t,n){return"".concat(e,"#").concat(t,"#").concat(n)},c=function(){function e(t,n,i,r){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._apiRoot=t,this._channelManager=i,this._socket=n,this._version=r,this._listenerManager=new o(void 0,(function(e){return a._services.log(e)})),this._socketListenerManager=new o(void 0,(function(e){return a._services.log(e)})),this._pendingWriteState={},this._pendingWriteDependencyMap={},this._stringMap={},this._addSocketListener("message",(function(e){return a._onMessage(e)}))}var t,n;return t=e,(n=[{key:"_onMessage",value:function(e){var t=this;if(this._pendingStringId)return this._log("RECEIVE STRING ".concat(this._pendingStringId)),this._stringMap[this._pendingStringId]=e,void delete this._pendingStringId;if(":"!==e[0]){var n=JSON.parse(e,(function(e,n){if("manifest"===e&&t._stringMap[n]){var i=t._stringMap[n];return delete t._stringMap[n],i}return n}));this._log("RECEIVE ".concat(this._getLogMessage(n.type,n.data))),this._listenerManager.notify(n.type,[n.data])}else this._pendingStringId=e}},{key:"_addSocketListener",value:function(e,t){this._socketListenerManager.add(e,t),this._socket.addListener(e,t)}},{key:"_removeSocketListeners",value:function(){var e=this;this._socketListenerManager.forEach((function(t,n){return e._socket.removeListener(t,n)})),this._socketListenerManager.removeAll()}},{key:"_log",value:function(e){this._logCallback&&this._logCallback(e)}},{key:"_getLogMessage",value:function(e,t){var n=e;return"syncstate"===e&&(n+=" ".concat(t.cloudId,": ").concat(t.state)),n}},{key:"setPendingWriteState",value:function(e,t,n){var i=s(e,t,n);this._pendingWriteState[i]=!0}},{key:"setPendingWriteDependency",value:function(e,t,n,i,o,r){var a=s(e,t,n),c=s(i,o,r);a!==c&&(this._pendingWriteDependencyMap[a]=this._pendingWriteDependencyMap[a]||{},this._pendingWriteDependencyMap[a][c]={userId:i,cloudId:o,id:r})}},{key:"clearPendingWriteState",value:function(e,t,n){var i=this,o=s(e,t,n),r=[];return Object.keys(this._pendingWriteDependencyMap[o]||{}).forEach((function(e){r.push(i._pendingWriteDependencyMap[o][e])})),delete this._pendingWriteState[o],delete this._pendingWriteDependencyMap[o],r}},{key:"getPendingWriteState",value:function(e,t,n,i){var o=this,r=s(e,t,n),a=!1;return!i&&this._pendingWriteState[r]&&(a=this._pendingWriteState[r]),Object.keys(this._pendingWriteDependencyMap).forEach((function(e){o._pendingWriteDependencyMap[e][r]&&(a=o._pendingWriteState[e]||a)})),a}},{key:"setLogCallback",value:function(e){this._logCallback=e}},{key:"addListener",value:function(e,t){this._listenerManager.add(e,t)}},{key:"removeListener",value:function(e,t){this._listenerManager.remove(e,t)}},{key:"send",value:function(e,t){var n=this;if(!this._channelManager||this._disableMiddleware)return this._send(e,t);var i=this._channelManager._middleware.filter((function(e){return e.checkVersion(n.version)}));this._disableMiddleware=!0;var o=!0,r=!1,a=void 0;try{for(var s,c=i[Symbol.iterator]();!(o=(s=c.next()).done);o=!0)if(!1===(t=s.value.middleware(this,e,t)))return void(this._disableMiddleware=!1)}catch(e){r=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(r)throw a}}this._disableMiddleware=!1,this._send(e,t)}},{key:"_send",value:function(e,t){var n=this;try{this._log("SEND ".concat(this._getLogMessage(e,t)));var i=JSON.stringify({type:e,data:t},(function(e,t){if("manifest"===e&&"function"==typeof t&&(t=t(n._version<21)),"manifest"===e&&n._version>=16){var i=":"+n._services.uuid();return n._log("SEND STRING ".concat(i)),n._socket.send(i),n._socket.send(t),i}return t}));this._socket.send(i)}catch(e){this._log("ERROR ".concat(e)),this._socketListenerManager.notify("error",[e])}}},{key:"addCallListener",value:function(e,t){var n=this;this.addListener(r(e),(function(i){var o=i.id;t(i.data,(function(t){n.send(a(e),{id:o,data:t})}))}))}},{key:"removeCallListener",value:function(e,t){this.removeListener(r(e),t)}},{key:"call",value:function(e,t,n){var i=this,o=this._services.uuid();this.addListener(a(e),(function t(r){r.id===o&&(i.removeListener(a(e),t),n(r.data))})),this.send(r(e),{id:o,data:t})}},{key:"onOpen",value:function(e){this._addSocketListener("open",e)}},{key:"onClose",value:function(e){this._addSocketListener("close",e)}},{key:"onError",value:function(e){this._addSocketListener("error",e)}},{key:"shutdown",value:function(){var e=this;this._addSocketListener("close",(function(){e._removeSocketListeners(),e._listenerManager.removeAll()}));try{this._socket.close()}catch(e){}}},{key:"_services",get:function(){return this._apiRoot._services}},{key:"version",get:function(){return this._version}}])&&i(t.prototype,n),e}();e.exports=c},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(7),r=function(){function e(t,n,i,r,a){var s=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var c=i?"wss://".concat(i,":").concat(t):"ws://127.0.0.1:".concat(t);c+="/?version=".concat(r),n&&(c+="&token=".concat(n)),this._socket=new WebSocket(c),this._socket.onopen=function(){return s._listenerManager.notify("open")},this._socket.onclose=function(){return s._listenerManager.notify("close")},this._socket.onmessage=function(e){return s._listenerManager.notify("message",[e.data])},this._socket.onerror=function(e){return s._listenerManager.notify("error",[e])},this._listenerManager=new o(["open","close","message","error"],a)}var t,n;return t=e,(n=[{key:"send",value:function(e){this._socket.send(e)}},{key:"addListener",value:function(e,t){this._listenerManager.add(e,t)}},{key:"removeListener",value:function(e,t){this._listenerManager.remove(e,t)}},{key:"close",value:function(){this._socket.close(),this._socket.onopen=void 0,this._socket.onclose=void 0,this._socket.onmessage=void 0,this._socket.onerror=void 0,this._listenerManager.removeAll()}}])&&i(t.prototype,n),e}();e.exports=r},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._storageInterface=t}var t,i;return t=e,(i=[{key:"_fsCall",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];var o="function"==typeof n[n.length-1]?n.pop():function(){};this._storageInterface._channel.call("fscall",{method:e,args:n},(function(e){return o.apply(null,e)}))}},{key:"rename",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["rename"].concat(t))}},{key:"stat",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["stat"].concat(t))}},{key:"unlink",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["unlink"].concat(t))}},{key:"rmdir",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["rmdir"].concat(t))}},{key:"mkdir",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["mkdir"].concat(t))}},{key:"readdir",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["readdir"].concat(t))}},{key:"utimes",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["utimes"].concat(t))}},{key:"readFile",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["readFile"].concat(t))}},{key:"writeFile",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["writeFile"].concat(t))}},{key:"copyFile",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["copyFile"].concat(t))}},{key:"exists",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["exists"].concat(t))}}])&&n(t.prototype,i),e}();e.exports=i},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=n(4),r=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._apiRoot=t}var t,n;return t=e,(n=[{key:"generateUuid",value:function(){return this._services.uuid()}},{key:"copyFile",value:function(e,t,n,i){var o=this;if(n)return this._services.fileUtils.copyFile(e,t,i);var r=this._services.getFileNameFromPath(t);this._services.fileUtils.getAvailablePath(t.substring(0,t.indexOf(r)),r,(function(t,n){return t?i(t):o._services.fileUtils.copyFile(e,n,i)}))}},{key:"getFileSize",value:function(e,t){this._services.fileUtils.statFile(e,(function(e,n){return t(e,n&&n.size)}))}},{key:"getInstalledVersion",value:function(e){return(this._config.ELEMENT_ACTION_PRODUCT_MAP.installedApps||[]).filter((function(t){return t.code.toLowerCase()===e.toLowerCase()})).map((function(e){return e.version})).sort(o.compareVersions)[0]}},{key:"_services",get:function(){return this._apiRoot._services}},{key:"_config",get:function(){return this._apiRoot._config}}])&&i(t.prototype,n),e}();e.exports=r},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._apiRoot=t}var t,i;return t=e,(i=[{key:"reportUseElement",value:function(e,t,n){this._analytics.reportUseElement(e,t,n)}},{key:"reportCheckoutElement",value:function(e,t,n){this._analytics.reportCheckoutElement(e,t,n)}},{key:"reportCreateLink",value:function(e,t){this._analytics.reportCreateLink(e,t)}},{key:"reportShareElementLink",value:function(e){this._analytics.reportShareElementLink(e)}},{key:"reportShareLibraryLink",value:function(e){this._analytics.reportShareLibraryLink(e)}},{key:"_analytics",get:function(){return this._apiRoot._analytics}}])&&n(t.prototype,i),e}();e.exports=i}])}).call(this,n("tjlA").Buffer)}}]);